Call multiple fscommand functionslink
var interval = setTimeout(function ()
{
fscommand("file_write;text.txt","content");
}, 0);
Force minimum size of windowlink
The window can't be resized to a size smaller than 500x250.
Delete a filelink
Enable / Disable key handlinglink
fscommand("default_handling","ALT-");
Prevents that ALT key selects the system menu. Use ALT+ to restore original behaviour.
fscommand("default_handling","ESC-");
Prevents exit of full screen if escape key is pressed. Use ESC+ to restore original behaviour.
Quit the programlink
Quit / Close / Exit the program
Set the window titlelink
Set the window title
Window Sizelink
fscommand("fullscreen","fullscreen");
Set window to fullscreen
fscommand("fullscreen","true");
Set window to maximized
fscommand("fullscreen","false");
Set window to resizable
fscommand("fullscreen","min");
Set window to minimized
fscommand("fullscreen","hide");
Set window to 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.
Always on Toplink
Force the window to stay always on top / as foremost window
Window move & resize with the mouselink
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
Right Mouse Button Click Eventlink
If the default context menu is disabled in the FlashBuilder options, showContextMenu is called on a right mouse button click.
AS2 Example:
ExternalInterface.addCallback("showContextMenu", null, showContextMenu);
function showContextMenu(sData:String, sData2:String, sData3:String):Void
{
}
AS3 Example:
ExternalInterface.addCallback("showContextMenu", showContextMenu);
function showContextMenu(dummy1:String, dummy2:String, dummy3:String): String
{
return "";
}
Get Keyboard Statelink
Shift Key: 16
Control Key: 17
Alt Key: 18
AS3: content=ExternalInterface.call("keyboardGetState","16");
Returns 1 if the shift key is pressed, 0 if it’s not pressed
AS2: fscommand("keyboard_get_state;16","result.text");
Sets result.text to 1 if the shift key is pressed, 0 if it’s not pressed
Start a program, open a file or open the browserlink
fscommand("real_exec;command line options","app.exe");
Executes a file which is in the same folder as the executable
You can use environment variables like %APPDATA%
real_exec - Start application, open file or open browser
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 folder
fscommand("real_exec","http://www.google.com/");
Open default browser and show the url
Window Positionlink
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/rotationlink
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/Resizelink
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 Scalinglink
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 Optionslink
ExternalInterface.call("commandline","key");
Returns the value command line option from /key <value>
ExternalInterface.call("commandline","@");
Returns all command line options
Reading & Writing any filelink
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.
file_append and file_append_text will append the content to the file instead of overwriting the file content.
Search for fileslink
This will return the matching files and folder in the format <name>|<size>|<creation time>|<modification time>;
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
Clipboardlink
fscommand("clipboard_set","text");
Insert text into the clipboard
content=ExternalInterface.call("clipboardGet");
Returns the content of the clipboard, this is only available in AS3
fscommand("clipboard_get","clip.text");
Sets clip.text to the content of the clipboard, only required for AS2
Create a Folderlink
fscommand("directory_create","C:\folder\to\create\");
Create the specified folder
File Open / File Save Dialoglink
content=ExternalInterface.call("selectFile","save;title;*.txt;file.txt");
Returns the selected file name, this is only available in AS3
fscommand("select_file","open;title;*.txt;file.txt;result.text");
Sets result.text to the selected file name, only required for AS2
Web Uploadlink
content=ExternalInterface.call("webUpload;http://www.example.com/;param=foo;file=@bla.txt");
Posts bla.txt to www.example.com, this is only available in AS3
fscommand("web_upload;http://www.example.com/;param=foo;file=@bla.txt","result.text");
Posts bla.txt to www.example.com, sets result.text to the returned data, only required for AS2
Web Downloadlink
content=ExternalInterface.call("webDownload","http://www.example.com/;;bla.txt");
Downloads www.example.com to bla.txt, this is only available in AS3
fscommand("web_download;http://www.example.com/","result.text");
Downloads www.example.com and sets result.text to the returned string, only required for AS2
Registry Accesslink
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 Playerlink
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 (for example from C:\Windows\SysWOW64\Macromed\Flash\Flash.ocx) as Helper.ocx into the installation folder (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.
No Adobe Flash Player installedlink
The program requires the Adobe Flash Player.
You can search with Google for a 32 Bit version of Flash.ocx.
Alternatively, Windows might have a copy at C:\Windows\SysWOW64\Macromed\Flash\Flash.ocx.
Rename the file to Helper.ocx and place it in the folder where the program is located. Then you can restart the program.
Assets Folderlink
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.
loadMovie("movie.swf@assets",""); loads the movie from the assets folder.
If a file called ‘flashnotify.bat’ is present, it is called with ‘start’ or ‘end’ and the application file name as command line parameter.
Get application versionlink
This command will return the application version:
version=ExternalInterface.call("versionGet");
Middle Mouse Button Click Eventlink
If the middle mouse button is pressed, middleButtonPressed is called.
AS2 Example:
ExternalInterface.addCallback("middleButtonPressed", null, showContextMenu);
function middleButtonPressed(sData:String, sData2:String, sData3:String):Void
{
}
AS3 Example:
ExternalInterface.addCallback("middleButtonPressed", showContextMenu);
function middleButtonPressed(dummy1:String, dummy2:String, dummy3:String): String
{
return "";
}
Settingslink
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 Iconlink
You can show and hide an icon in the shell tray bar:
fscommand("shellicon","show");
fscommand("shellicon","hide");
Animated cursor supportlink
Transparent Text Drawing Issueslink
Alternatively you can select in the FlashBuilder ‘Transparent Background with transparent text fix’.