author: Krasimir Tsonev

Hi there, I'm . Senior front-end engineer with over 13 years of experience. I write, speak and occasionally code stuff.

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. Or maybe comment below: