Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create exit button in Flash application

I'm creating a Flash Application that will be exported in exe format and it's not going to run in browser. I want to add an exit button inside stage but I don't know how to do that with ActionScript 3.

I remember that it was possible with fscommand in ActionScript 2 but it's not working in AS3.

I've searched everywhere but everyone is trying to close a popup or tab or window all in browser environment not a Flash app.

like image 220
Farid Rn Avatar asked Jan 26 '12 16:01

Farid Rn


4 Answers

Why would use a .exe format when you can now export as3 application as AIR? BUT If you still want the exe, I think that this will work

 import flash.system.fscommand;

 //Then you can use the following function for the button click handler:

 private function clickHandler(event:MouseEvent):void {
      fscommand("quit");
 }

If you decide to try the AIR solution, this is the command

 import flash.desktop.NativeApplication;
 nativeApp.nativeApplication.exit();
like image 62
Sr.Richie Avatar answered Nov 18 '22 05:11

Sr.Richie


It's still an fscommand, but the syntax is different:

import flash.system.fscommand;

btn.addEventListener(MouseEvent.MOUSE_DOWN, closeApp);

function closeApp(event:MouseEvent):void {
    fscommand("quit");
}
like image 30
Martin Avatar answered Nov 18 '22 05:11

Martin


System.exit(0); should close a desktop application?

like image 3
L7ColWinters Avatar answered Nov 18 '22 04:11

L7ColWinters


Try:

 import flash.system.fscommand;

 function clickHandler(event:MouseEvent):void {
 fscommand("quit");
 }

 btn.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
like image 3
AsTheWormTurns Avatar answered Nov 18 '22 04:11

AsTheWormTurns