How do I respond to an autoexit when the application window is closed.
according to the AIR 1.5 docs
''When an exit command is mediated through the operating system by one of these routes, the NativeApplication dispatches an exiting event. If no listeners cancel the exiting event, any open windows are closed. Each window dispatches a closing and then a close event. If any of the windows cancel the closing event, the shut-down process stops.''
I have tried adding an event listener in the constructor for the application
this.addEventListener(Event.EXITING,onExiting);
AutoExit is set to true, the application terminates when the window close button is used but no EXITING event is recieved therefore onExiting is not executed.
Can someone show me the correct way to do it?
close button autoexitAre you cancelling the event (by calling the preventDefault() method)? The following should work:
NativeApplication.nativeApplication.autoExit = true;
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
function onExiting(event:Event):void
{
?event.preventDefault();
?trace(''onExiting() handler'');
}?
Ok so
this.addEventListener(Event.EXITING,onExiting);
does not work but
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
does
Thank you.
No comments:
Post a Comment