Skip to main content
Known Participant
September 11, 2011
Answered

Exit button.

  • September 11, 2011
  • 1 reply
  • 3434 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 has been closed for replies.
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

1 reply

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