Skip to main content
Known Participant
September 11, 2011
Answered

Exit button.

  • September 11, 2011
  • 4 replies
  • 3437 views

I want to add "Exit" button to my app, used this code:

exit.addEventListener(MouseEvent.CLICK, exitHandler);

function exitHandler(e:MouseEvent):void{
fscommand("quit");
}
But it is not working, after click nothing happens.
Are there any mistakes in code or other solution?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer blazejewicz

Hi,

function exitHandler(event:MouseEvent):void

{

          NativeApplication.nativeApplication.exit();

};

Also specific to Android OS:

http://blogs.adobe.com/flashplatform/2010/10/tip-close-your-android-air-app-on-back-button.html

regards,

Peter

4 replies

Participating Frequently
September 11, 2011

Hello,

You are supposed to use 'exit' method of NativeApplication. See docs link:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeApplication.html#exit()

FScommand - and native "exit" - as documented here:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/System.html#exit()

are for Flash runtime - not Air runtime.

hth,

regards,

Peter

playa_12Author
Known Participant
September 12, 2011

I am soory, but I still didn't get it.

How can I add that exit() to button listener?

blazejewiczCorrect answer
Participating Frequently
September 12, 2011

Hi,

function exitHandler(event:MouseEvent):void

{

          NativeApplication.nativeApplication.exit();

};

Also specific to Android OS:

http://blogs.adobe.com/flashplatform/2010/10/tip-close-your-android-air-app-on-back-button.html

regards,

Peter