5

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.

Farid Rn
  • 3,167
  • 5
  • 39
  • 66

5 Answers5

10

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();
Sr.Richie
  • 5,680
  • 5
  • 38
  • 62
  • Umm, actually I have no idea about AIR and I'm a in hurry for completing my project, I will take a look at it later. – Farid Rn Jan 26 '12 at 17:07
  • Can AIR apps run on Mac as well? Do they need to have AIR installed or can you do it form the Flash IDE? – Papa De Beau Jun 28 '14 at 23:51
  • @PapaDeBeau yes, AIR app run on Mac too. About your second question, I don't understand it completely sorry. – Sr.Richie Jun 29 '14 at 11:22
  • 1
    Correction: Last line of code: From `nativeApp.nativeApplication.exit();` To Correct code `NativeApplication.nativeApplication.exit(); ` – ejbytes Feb 10 '17 at 21:50
4

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");
}
Mar
  • 7,765
  • 9
  • 48
  • 82
3

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

L7ColWinters
  • 1,342
  • 1
  • 14
  • 31
3

Try:

 import flash.system.fscommand;

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

 btn.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
AsTheWormTurns
  • 1,318
  • 3
  • 13
  • 26
0
function exitAdobe (event:MouseEvent): void {

NativeApplication.nativeApplication.exit();

}
bt_exit.addEventListener(MouseEvent.CLICK, exitAdobe);

//A melhor forma que encontrei...
Smita Ahinave
  • 1,901
  • 7
  • 23
  • 42