I'm experimenting with AIR after having learned AS3 recently. In the AIR test app that I am creating, I want to detect an application close in order to prompt the user for saving. I looked at the documentation and some articles and this is what I have so far:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, closeApplication);
public function closeApplication(e:Event):void
{
trace("don't exit");
e.preventDefault();
trace(e.isDefaultPrevented);
}
It doesn't seem to work though, I even tried Event.CLOSING, which does not even enter the function. The above code throws no errors, the string "don't exit", outputs true for the isDefaultPrevented, but still terminates. How do I intercept or overwrite the application exit in order to insert the prompt?
By the way, I'm using pure AS3, as I'm not yet that familiar with Flex yet.
Hope someone can guide me. Thanks!