Skip to content

Instantly share code, notes, and snippets.

@peterblazejewicz
Created June 3, 2011 11:15
Show Gist options
  • Save peterblazejewicz/1006205 to your computer and use it in GitHub Desktop.
Save peterblazejewicz/1006205 to your computer and use it in GitHub Desktop.
prevent CMD+Q default action
import mdm.Application;
import mx.controls.Alert;
import mx.events.CloseEvent;
//
// when application starts
// enable exit handler
// and route exit event to custom handler
// to get user action
//
private function initApp():void
{
mdm.Application.enableExitHandler();
mdm.Application.onAppExit = myExitHandler;
};
//
// called when application is to quit
// e.g. as results of CMD+Q
//
private function myExitHandler():void
{
mx.controls.Alert.show("Do you want to quit?", "EXIT", Alert.YES | Alert.CANCEL, this, closeHandler);
};
//
// if YES then exit
//
private function closeHandler(event:CloseEvent):void
{
if(event.detail == Alert.YES)
{
mdm.Application.exit();
} else
{
// nothing
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment