Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

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.