AS3: Exit desktop flash player - actionscript-3

How do I exit the desktop flash player using Actionscript 3?
System.exit(0);
Results in
SecurityError: Error #2018: System.exit is only available in the
standalone Flash Player.
The error appears both while previewing the project in Flash CS6 and while playing the exported swf-file in Flash Player Debugger.

You can use
fscommand("quit");
This will terminate your swf.
Don't forget to import fscommand:
import flash.system.fscommand;

There is a difference between Flash Player and the stand alone version.
When you export a fla, you export a swf that is played by flash player. Its not stand alone.
Just compile it, then go to File -> Create projector. Now its a stand alone and System.exit(0) should work.

How about:
NativeApplication.nativeApplication.exit();

Related

Flash CC on OS X: Where is the ActionScript 3.0 library?

For the life of me, I can't find the AS3 lib. I know in Flash CS6, I can find it at:
/Applications/Adobe Flash CS6/Common/Configuration/ActionScript 3.0/libs
I need to point my IDE at it, and the company I'm at can ONLY use Flash CC going forward (Corporate reasoning), and I'm the first one on the team to have to use Flash CC. My workaround is to use a trial version of CS6, but I'd like to figure this out.
Flash CC supports AS3, so the library has to be somewhere, right? If not, how does it function without it?
Thanks!
It's inside the app package:
/Applications/Adobe Flash CC 2015/Adobe Flash CC 2015.app/Contents/Common/Configuration/ActionScript 3.0/libs
To navigate to this folder, right click on the Adobe Flash CC 2015.app and choose "Show Package Contents".

is it possible to open external swf in new flash player with AS3 or AS2?

is it possible to open external swf in new flash player with AS3 or AS2? I've been searching everywhere for this, but most of what i found is that it's loading into new browser tab not other flash player.
There is no function to execute a new Flash Player.
If you think in this way: Flash Player is an executable in visitor's computer. If you can launch Flash Player, you can launch any executable you want. This causes security problem.
Therefore, you can't launch a new Flash Player.
fscommand(exec) only works with Windows Projector(exe) File, not SWF.

I need to import something in order to use JSON in AS3?

When using the following codeline:
var myjson:Object = JSON.parse("path_to_my.json");
I got the following error:
1120: Access of undefined property JSON.
I had to import any package in order to use the JSON.parse?
Thank you!
[with: Flash CS5 (11.0.0.485), AS3]
JSON is built in to the ActionScript default package starting at Flash Player 11, and is notably higher performance than 3rd party serializers.
With Flash CS5, you need to update the target Flash Player from the Publish Settings. By default it will target up to Flash Player 10.2.
Adobe has a blog regarding Adding Flash Player 11 support to Flash Pro CS5 and CS5.5.
At that page you will find an extension (MXP) install as well as manual instruction of updating Flash Player to 11.
Load CS5 or CS.5 MXP with Adobe Extension Manager, and you will be able to target Flash Player 11.0 from your Publish Settings:
Note that JSON parse takes an object, and not a path to a file.  Your code should give Error #1132: Invalid JSON parse input.

How to debug/step through external/loaded swf - FlashProfessional?

(Flash Professional / AS3)
I have a main fla file that loads a game (with a Loader) and adds it to the stage (addChild(myLoader)). Is there a way to step through/debug the loaded swf? If so, how? My game.swf breakpoints aren't hitting.
Did you debug (Control > Debug Movie) both files?
You need to debug both Main and Game to be able to get breakpoints in the loaded SWF to work. When you Debug a SWF, extra information is added to the file. If you just publish the file there will not be any debug info.
You could try using MonsterDebugger.

Close Flash Player from FlashDevelop IDE

Whenever I compile my project using FlashDevelop in 'Debug' the Flash Player window remains after I have clicked the 'Stop' button in Flash Develop. I have to then switch over to the flash player, click through any error messages and then close the player, which wastes a lot of time in the long run.
Any way to make it so Flash Player closes when I click 'Stop' in the Flash Develop debug tools?
EDIT:
My setup is a fresh install of Windows 7, a new copy of Flash Develop 4 and Flash Player 10.
You may disable the error popup in your Flash Player by editing your mm.cfg file (which is in your Windows' user folder). Just add the following:
SuppressDebuggerExceptionDialogs=1
Then the Flash Player will nicely be killed when you stop FlashDevelop debugging. BTW, you will still be able to read the errors in the trace.
In FlashDevelop/Settings/ToolBar.xml just put this line
<button label="Kill FlashPlayer" click="RunProcess" tag="taskkill;/f /t /im FlashPlayerDebugger.exe" image="197" />
and restart FD.
I've asked this question in the Flash Develop forums and an admin informed me that this is a feature that they are currently thinking about including but that it FD cannot close the Flash Player atm.
http://www.flashdevelop.org/community/viewtopic.php?f=13&t=8442&sid=be1affc07163323a49000722e6b86ce1&p=39291#p39291