Reputation: 11
How can i create an exit button from my application using Air for Android Flash Professional CS6. do I need to create a button? and what is the code for that?
thanks in advance
Upvotes: 1
Views: 16221
Reputation: 577
Here you have AIR solution, this should work.
1) Create a button
2) Add Event listener to the button
button.addEventListener(MouseEvent.CLICK, exitHandler );
3) copy and paste this code to your project
import flash.desktop.NativeApplication;
//Then you can use the following function for the button click handler:
function exitHandler (event:MouseEvent):void
{
NativeApplication.nativeApplication.exit();
}
merry christmas =)
EDIT
Hi. I just now saw your comment. And to test, I created a new project of type AIR for Android. First I added a button to stage, and gave it a name of "btn_exit". And the only AS3 I have is this:
import flash.events.TouchEvent;
import flash.desktop.NativeApplication;
stop();
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
btn_exit.addEventListener(TouchEvent.TOUCH_END, exitApp);
function exitApp(event:TouchEvent):void {
NativeApplication.nativeApplication.exit();
}
This should work for you. xD
Upvotes: 1