• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ActionScript code to close the program

New Here ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

Does anyone know the ActionScript code to close the .swf file?  I want the user to be able to click on a button, which will call a function that closes the .swf file, but I don't know the correct method to use.  Using the structure below, what code would go inside the function?

exit_btn.addEventListener(MouseEvent.CLICK, closeProgram);

function closeProgram(event:MouseEvent):void   {      


}

TOPICS
ActionScript

Views

4.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

Hi.

Try this:

// USING THE FLASH PLAYER

import flash.system.fscommand;

function closeProgram(event:MouseEvent):void

{

    fscommand("quit");

}

exit_btn.addEventListener(MouseEvent.CLICK, closeProgram);

// OR

// USING ADOBE AIR

import flash.desktop.NativeApplication;

function closeProgram(event:MouseEvent):void

{

    NativeApplication.nativeApplication.exit();

}

exit_btn.addEventListener(MouseEvent.CLICK, closeProgram);

I hope it helps.

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

It doesn't seem to be working.  It doesn't crash or error out, just sits there when I click on the button. So this is what I've got:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

LATEST

If you are using the Flash Player and you are testing from within Animate CC, it won't close. Go to your file explorer and run the SWF from there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines