Adobe AIR: how to make things upon closing the application

Blog / ActionScript ·

Sometimes we need to catch the closing of our AIR application to make some things like storing the window's position and size. We can do that in our code.

What we need is to add a listener to our nativeWindow.

stage.nativeWindow.addEventListener(Event.CLOSING, onNativeWindowClosing);

and then to prevent the closing of the application till we do what we want:

private function onNativeWindowClosing(e:Event):void {		// prevent the closing of the application	e.preventDefault();		// ...	// do some things here	// ...		// close the application	NativeApplication.nativeApplication.exit();	}

Krasimir Tsonev With over two decades of deep programming expertise, I offer comprehensive web consultancy and stack audits, alongside specialized workshops, training, and engaging public speaking to elevate your team's skills and optimize your digital presence. Contact me.

Keywords: application closing things
Share the post on Twitter, Facebook, LinkedIn