Miscellaneous fscommand(command:String,argument:String) commandslink
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, 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.
Search for fileslink
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
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");
Mouse Click Eventslink
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
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’.