Flash Builder/Flash Player
Flash Builder/Flash Player
Convert SWF file into borderless & translucent EXE application

Miscellaneous fscommand(command:String,argument:String) commands

fscommand("set_title","Window Title");
Sets the window title

fscommand("quit","");
Exit the program

fscommand("fullscreen","fullscreen"); / fscommand("fullscreen","true"); / fscommand("fullscreen","false"); / fscommand("fullscreen","min"); / fscommand("fullscreen","hide");
Set window to fullscreen / maximized / resizable / minimized / hidden.
Download FlashFullScreen AS3 sample. It shows the different fullscreen, startup window mode and scaling options. You must select ‘Solid Background’ in the FlashBuilder to get this to work.

fscommand("command","move"); on MouseEvent.MOUSE_DOWN / fscommand("command","mouse_up");
On MouseEvent.MOUSE_UP – drag the window

fscommand("command","resize"); on MouseEvent.MOUSE_DOWN / fscommand("command","mouse_up");
On MouseEvent.MOUSE_UP – resize the window

fscommand("always_on_top","yes");
Force the window to stay always on top / as foremost window

Start a program or open a file

fscommand("real_exec;command line options","app.exe");
Executes a file which is in the same directory as the executable
You can use environment variables like %APPDATA%

real_exec Start the application
real_exec_hidden Start the application hidden
real_exec_and_wait Start the application and wait for termination
real_exec_and_wait_hidden Start the application hidden and wait for termination

Use assets:test.bat to access files in the assets folder fscommand("exec","app.exe");
Executes a file which is located in the fscommand subdirectory

Window Position

size_and_position=ExternalInterface.call("position");
Get size & position, it will return a string like “leftxtop widthxheight”

fscommand("position","100x200 300x400");
Set position and size, ommit second part if no resize is needed

fscommand("position","save"); / fscommand("position","restore"); / fscommand("position","clear");
Save, restore and clear window position

Screen orientation/rotation

fscommand("orientation","90");
Set screen orientation 0 / 90 / 180 / 270

ExternalInterface.call("getOrientation");
Get screen orientation 0 / 90 / 180 / 270

fscommand("auto_rotation","none");
Set the screen auto-rotation preferences to none / landscape / portrait / landscape_flipped / portrait_flipped

ExternalInterface.call("getAutoRotation");
Get screen auto-rotation preferences none / landscape / portrait / landscape_flipped / portrait_flipped

Scaling/Resize

The flash window can be shown in four different scale modes. You can decide whether it should be resized to fullscreen or stay at design size. Just enter in the first frame one line of action script:

AS2: Stage.scaleMode = "exactFit";

AS3: stage.scaleMode = StageScaleMode.EXACT_FIT;

Here are the four different modes explained: AS2 scaleMode property and AS3 scaleMode property.

No Scaling

To show the flash window in the original size a.k.a. ‘No Scaling’, add following action script code:

AS2:
_root.StageWidth=Stage.width;
_root.StageHeight=Stage.height;
Stage.scaleMode = "noScale";

AS3:
function getSize(dummy1:String,dummy2:String,dummy3:String): String
{
   return loaderInfo.width+"x"+loaderInfo.height;
}
ExternalInterface.addCallback("getSize",getSize);
stage.scaleMode = StageScaleMode.NO_SCALE;

Command Line Options

ExternalInterface.call("commandline","key");
Returns the value command line option from /key <value>

ExternalInterface.call("commandline","@");
Returns all command line options

Reading & Writing any file

fscommand("file_write;text.txt","content");
Writes ‘content’ into the file ‘text.txt’

content=ExternalInterface.call("fileRead","text.txt");
Returns the content of ‘text.txt’, this is only available in AS3

fscommand("file_read;text.txt","read_content.text");
Sets read_content.text to the content of ‘text.txt’, only required for AS2

file_read_text and file_write_text will replace new lines with the windows version of line feeds and store the text as UTF-8.

AS3 Sample DownloadAS2 Sample Download

Search for files

This will return the matching files and folder in the format <name>|<size>;
If the pattern starts with the @ sign, all sub folders are searched, otherwise only the specified folder is searched.
You can use environment variables like %APPDATA%

content=ExternalInterface.call("fileFind","*.*");
Returns all files and folders matching the given pattern, this is only available in AS3

fscommand("file_find;pattern","result.text");
Sets result.text to all files and folders matching the given pattern, only required for AS2

Registry Access

fscommand("registry_write;key","content");
Writes ‘content’ into the registry at ‘key’. ‘key’ can be for example: HKEY_CURRENT_USER\path\key. Prepend ‘key’ with DWORD\ to force REG_DWORD access instead of REG_SZ.

content=ExternalInterface.call("registryRead","key");
Returns the content of ‘key’, this is only available in AS3

fscommand("registry_read;key","read_content.text");
Sets read_content.text to the content of ‘key’, only required for AS2

Flash Player

The generated executable requires a installed Adobe Flash player. In case of too old or non existing Adobe Flash player, the executable will show a message box and ask for installation of the Adobe Flash player.

If you want to bundle the Adobe Flash player with the exeuctable, copy the 32 bit version of the Flash.ocx as Helper.ocx into the installation directory (where FlashBuilder.exe is located). The FlashBuilder application will detect this and include the Helper.ocx into the generated executable.
This will allow the generated executable to run on computers, even if there is no installed Adobe Flash player.

Assets Folder

If the option is enabled, all files from the ‘assets’ folder are included in the generated executable. You can call ExternalInterface.call("getAssetsFolder"); to get the temporary folder where all files are extracted.

If a file called ‘flashnotify.bat’ is present, it is called with ‘start’ or ‘end’ and the application file name as command line parameter.

Mouse Click Events

function middleButtonPressed(sData:String,sData2:String,sData3:String):Void
This function is called, if the middle mouse button is pressed

function showContextMenu(sData:String,sData2:String,sData3:String):Void
This function is instead called, if the right mouse button click context menu is disabled

Settings

You can store and read key/value pairs in the registry or in an ini file.

The ini file will be used if the key starts with an @ sign:
fscommand("setting","@foo=bar");
value=ExternalInterface.call("setting","@foo");

Otherwise the registry will be used:
fscommand("setting","foo=bar");
value=ExternalInterface.call("setting","foo");

Shell Tray Icon

You can show and hide an icon in the shell tray bar:
fscommand("shellicon","show");
fscommand("shellicon","hide");

Animated cursor support

If a ‘Cursor.ani’ file is located in the same folder as the .SWF file, this file will be included in the FlashPlayer.exe and will be used as cursor.

Transparent Text Drawing Issues

To prevent that text in dynamic TextField controls is drawn transparently, add any Filter to the object. For example ‘Adjust Color’ with zero values. So no change in style will happen but the text is shown correctly.
Alternatively you can select in the FlashBuilder ‘Transparent Background with transparent text fix’.