My 5th book "50 Tips on JavaScript" is on sale. Go get it from https://50tips.dev.
Illustrated guide to 50 of the most interesting JavaScript topics.

Adobe AIR: how to make things upon closing the application

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();	}
If you enjoy this post, share it on Twitter, Facebook or LinkedIn. To leave a comment go here.