Contents
(1) All APIs are called via fscommand
(2) Fscommand is called in asynchronous mode. Please don't try to retrieve the return value immediately after a fscommand call. You must use "watch" method to monitor the change of the return value. e.g.:
_root.retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval; //handle the value
return newval;
}
_root.watch( "retValue", retValue_watch );...
fscommand("ReadFile", "data\\\\test.dat, _root.retValue" );
(3) use "\\\\" to represent a '\' in the parameters of the api. e.g.: "\\\\windows\\\\calc.exe". Or use '/' instead of '\'. e.g. : "/windows/calc.exe"
Quit()
The Quit function exits the current application.
Usage
fscommand("Quit","");
Parameters
None.
Returns
None.
Sample
on(press){
fscommand("Quit", "");
}
Fullscreen(true/false)
The Fullscreen function sets the window mode of the application.
Usage
fscommand("Fullscreen","true/false");
Parameters
true: Set the application to full-screen mode.
false: Return the application to normal window mode.
Returns
None.
Sample
fscommand("Fullscreen", "true");
ShowMenu(true/false)
The ShowMenu function enables or disables the menu of
the flash player. Specifying
true enables
the full set of context menu items. Specifying false removes the
context menu items.
Usage
fscommand("Fullscreen","true/false");
Parameters
true: Enable the context menu.
false: Disable the context menu.
Returns
None.
Sample
fscommand("ShowMenu", "true");
Exec(cmd)
The Exec function executes an external application.
Usage
fscommand("Exec", "cmd");
Parameters
cmd(in): command line for the application to be executed.
Returns
None.
Sample
fscommand("Exec","calc.exe");
fscommand("Exec","\\\\windows\\\\calc.exe");
ShowSIP(true/false)
The ShowSIP function shows or hides the input panel. Only available on Pocket PC.
Usage
fscommand("ShowSIP","true/false");
Parameters
true: Set the Flash application to full-screen mode.
false: Return the flash application to normal window mode.
Returns
None.
Sample
fscommand("ShowSIP", "true");
ShowSIPButton(true/false)
The ShowSIPButton function shows or hides the input panel button . Only available on Pocket PC.
Usage
fscommand("ShowSIPButton","true/false");
Parameters
true: Show the input panel button.
false: Hide the input panel button.
Returns
None.
Sample
fscommand( "ShowSIPButton", "false" );
ShowStartIcon(true/false)
The ShowStartIcon function shows or hides Start button icon on the navigation bar. Only available on Pocket PC.
Usage
fscommand("ShowStartIcon","true");
Parameters
true: Show Start button icon on the navigation bar.
false: Hide Start button icon on the navigation bar.
Returns
None.
Sample
fscommand( "ShowStartIcon", "false" );
GetDeviceID(id)
The GetDeviceID function gets the unique ID of the device. The ID is an unique 128-bit digital number. Only available on Pocket PC.
Usage
fscommand("GetDeviceID","id");
Parameters
id(out): Actionscript variable to receive the ID of device
Returns
id.
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....
on(press){fscommand( "GetDeviceID", "_root.retValue" );
}
GetOwnerInfo(name, email, address, phone, company)
The GetOwnerInfo function gets the name, email, address, phone, company information of the owner. Only available on Pocket PC.
Usage
fscommand("GetOwnerInfo","name, email, address, phone, company");
Parameters
name(out): Actionscript variable to receive the name of owner.
email(out): Actionscript variable to receive the email of owner.
address(out):Actionscript variable to receive the address of owner.
phone(out):Actionscript variable to receive the phone of owner.
company(out):Actionscript variable to receive the company of owner.
Returns
name, email, address, phone, company
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on (press) {
// fscommand( "GetOwnerInfo", "_root.retValue" ); //only get the user name
fscommand( "GetOwnerInfo", "0,_root.retValue" ); //only get the email
}
GxOpenInput()
The GxOpenInput function turns on the unfiltered button message mode. All hardware button presses will generate appropriate key events to the application and will not be sent to the shell. Call this function if you want handle the hardware button presses. Only available on Pocket PC.
Usage
fscommand("GxOpenInput","");
Parameters
None.
Returns
None.
Sample
fscommand("GxOpenInput", "");
GxCloseInput()
The GxCloseInput function releases any input-related resources used by GAPI and returns button-press messages to their filtered mode.
Only available on Windows CE.
Usage
fscommand("GxCloseInput","");
Parameters
None.
Returns
None.
Sample
fscommand("GxCloseInput", "");
SystemIdleTimerReset(timeout)
The SystemIdleTimerReset function resets a system timer that controls whether or not the device will automatically go into a suspended(power off) state.
Only available on Windows CE.
Usage
fscommand("SystemIdleTimerReset","timeout");
Parameters
timeout: Specifies the time, in seconds, for which to reset the timer.
Returns
None.
Sample
fscommand("SystemIdleTimerReset", "600");
GetSoundVolume(left, right)
The GetSoundVolume function queries the current volume setting of a sound output device. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
Usage
fscommand("GetSoundVolume","left, right");
Parameters
left(out): Actionscript variable that receives the volume of the left channel. the value is between 0x0000 and 0xffff.
right(out): Actionscript variable that receives the volume of the right channel. the value is between 0x0000 and 0xffff.
Returns
left, right.
Sample
leftValue = "";
rightValue ="";
function rightValue_watch(id, oldval, newval)
{
_root.textVar = leftValue + " " + newval;
return newval;
}
_root.watch( "rightValue", rightValue_watch );
....on (press) {
fscommand( "GetSoundVolume", "_root.leftValue, _root.rightValue" ); //get the volume of the left channel
}
SetSoundVolume(left, right)
The SetSoundVolume function sets the current volume of a sound output device. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence. If a device does not support both left and right volume control, the left volume setting specifies the volume level, and right volume setting is ignored.
Usage
fscommand("SetSoundVolume","left, right");
Parameters
left: The volume setting of the left channel. the value is between 0x0000 and 0xffff.
right: The volume setting of the right channel. the value is between 0x0000 and 0xffff.
Returns
None.
Sample
left = 0xffff/16 * 2; //for PDA which is only support 16-level sound voume
right = 0xffff/16 * 2;
fscommand( "SetSoundVolume", left +","+right );
GetWindowRect(left, top, width, height)
The GetWindowRect function gets the position and dimensions of current application .
Usage
fscommand("GetWindowRect","left, top, width, height");
Parameters
left(out): Actionscript variable that receives the x-coordinate of the upper-left corner of the window.
top(out): Actionscript variable that receives the y-coordinate of the upper-left corner of the window.
width(out): Actionscript variable that receives the width of the window.
height(out): Actionscript variable that receives the height of the window.
Returns
left, top, width, height.
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on (press) {
// fscommand( "GetWindowRect", "_root.retValue" ); //left
fscommand( "GetWindowRect", "0,_root.retValue" ); //top
// fscommand( "GetWindowRect", "0,0,_root.retValue" ); //width
// fscommand( "GetWindowRect", "0,0,0,_root.retValue" ); //height
}
MoveWindow(left, top, width, height)
The MoveWindow function changes the position and dimensions of current application.
Usage
fscommand("MoveWindow","left, top, width, height");
Parameters
left(in): Specfies new position of the x-coordinate of the upper-left corner of the window.
top(in): Specfies new position of the y-coordinate of the upper-left corner of the window.
width(in): Specifies the new width of the window.
height(in): Specifies the new height of the window.
Returns
None.
Sample
fscommand("MoveWindow", "0, 50, 200, 220");
GetWorkAreaRect(left, top, width, height)
The GetWorkAreaRect function gets the position and dimensions of the work area of the device. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars.
Usage
fscommand("GetWorkAreaRect","left, top, width, height");
Parameters
left(out): Actionscript variable that receives the x-coordinate of the upper-left corner of the work area of the device.
top(out): Actionscript variable that receives the y-coordinate of the upper-left corner of the work area of the device.
width(out): Actionscript variable that receives the width of the work area of the device.
height(out): Actionscript variable that receives the height of the work area of the device.
Returns
left, top, width, height.
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on (press) {
// fscommand( "GetWorkAreaRect", "_root.retValue" ); //left
fscommand( "GetWorkAreaRect", "0,_root.retValue" ); //top
// fscommand( "GetWorkAreaRect", "0,0,_root.retValue" ); //width
// fscommand( "GetWorkAreaRect", "0,0,0,_root.retValue" ); //height
}
GetScreenSize(width, height)
The GetScreenSize function gets the dimensions of the screen of the display.
Usage
fscommand("GetScreenSize","width, height");
Parameters
width(out): Actionscript variable that receives the width of the screen.
height(out): Actionscript variable that receives the height of the screen.
Returns
width, height.
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on (press) {
//declaration: GetScreenSize( width, height )
// fscommand( "GetScreenSize", "_root.retValue" ); //width
fscommand( "GetScreenSize", "0,_root.retValue" ); //height
}
ReadRegistryValue(key, subkey, valueName, type, error)
The ReadRegistryValue function retrieves the data associated with the specified registry key.
Usage
fscommand("ReadRegistryValue", "key, subkey, valueName, value, type, error" );
Parameters
key: The root key. It should be one of the following predifined values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_PERFORMANCE_DATA ( only for Windows NT/2000 )
HKEY_DYN_DATA ( only for Windows 95/98 )
subkey(in): Subkey of the registry key.
valueName(in): name of the value.
value(out): Actionscript variable that receives the value.
type(out): Actionscript variable that receives the type of the value. Currently only support two types: "SZ" and "DWORD" .
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the registry key
101: The value type is not supported.
1: Generic Error.
Returns
value, type, error
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on(press){
fscommand("ReadRegistry", "HKEY_CURRENT_USER, Software\\\\FlashApp, score, _root.retValue" );
}
WriteRegistryValue(key, subkey, vlaueName, type, value)
The WriteRegistry function sets the data and type of a specified value under a registry key.
Usage
fscommand("WriteRegistryValue", "key, subkey, valueName, type, value, error " );
Parameters
key(in): The root key. It should be one of the following predifined values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_PERFORMANCE_DATA ( only for Windows NT/2000 )
HKEY_DYN_DATA ( only for Windows 95/98 )
subkey(in): Subkey of the registry key.
valueName(in): Name of the value.
type(in): The type of the value. Currently only support two types: "SZ" and "DWORD" .
value(in): The value of the key.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the registry key
101: The value type is not supported.
1: Generic Error.
Returns
error
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....on (press) {
fscommand("WriteRegistryValue", "\"HKEY_CURRENT_USER\", \"Software\\\\FlashApp\", \"score\", \"SZ\", \"tom:1000;jerry:2000\", _root.retValue" );
}
DeleteRegistryValue(key, subkey, value, error)
The RegDeleteValue function removes a named value from the specified registry key.
Usage
fscommand("DeleteRegistryValue", "key, subkey, valueName, error " );
Parameters
key(in): The root key. It should be one of the following predifined values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_PERFORMANCE_DATA ( only for Windows NT/2000 )
HKEY_DYN_DATA ( only for Windows 95/98 )
subkey(in): Subkey of the registry key.
valueName(in): Name of the value.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the registry key
1: Generic Error.
Returns
error
Description
Removes a named value from the specified registry key.
Sample
on (press) {
fscommand("DeleteRegistryValue", "\"HKEY_CURRENT_USER\", \"Software\\\\FlashApp\", \"score\" );
}
DeleteRegistryKey(key, subkey, error)
The DeleteRegistryKey function deletes a subkey.
Usage
fscommand("DeleteRegistryValue", "key, subkey, error " );
Parameters
key(in): The root key. It should be one of the following predifined values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_PERFORMANCE_DATA ( only for Windows NT/2000 )
HKEY_DYN_DATA ( only for Windows 95/98 )
subkey(in): Subkey of the registry key.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the registry key
1: Generic Error.
Returns
error
Sample
on (press) {
fscommand("DeleteRegistryKey", "\"HKEY_CURRENT_USER\", \"Software\\\\FlashApp\" );
}
ReadFile(fileName, retValue, error)
The ReadFile function reads data from a file. Only support text file.
Usage
fscommand("ReadFile", "fileName, retValue, error" );
Parameters
fileName(in): The file name
retValue(in): Actionscript variable that receives the contents of the file.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the file
1: Generic Error.
Returns
retValue, error
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....
fscommand("ReadFile", "\"test.dat\", _root.retValue" );
WriteFile(fileName, value, error)
The WriteFile function writes data to a file. Only support text file.
Usage
fscommand("WriteFile", "fileName, value, error"
);
Parameters
fileName(in): The name of target file.
value(in): Buffer containing the data to be written to the file.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the file
1: Generic Error.
Returns
error
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....
fscommand("WriteFile", " \"test.dat\",\"this is a test\", _root.retValue ");
DeleteFile(fileName, error)
The DeleteFile function deletes an existing file.
Usage
fscommand( "DeleteFile", "fileName,
error" );
Parameters
fileName(in): the name of file to be delete.
error(out): Actionscript variable that receives the error code.
0: Succeeds
100: Can't open the file
1: Generic Error.
Returns
error
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "DeleteFile", " \"test.dat\", _root.retValue " );
GetWorkPath(path)
The GetWorkPath function return the path of the work directory.
Usage
fscommand( "GetWorkPath", "path" );
Parameters
path(out): Actionscript variable that receives the path.
Returns
path
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "GetWorkPath", " _root.retValue " );
GetModulePath()
The GetModulePath function returns the path of the application.
Usage
fscommand( "GetModulePath", "path" );
Parameters
path(out): Actionscript variable that receives the path.
Returns
path
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "GetModulePath", " _root.retValue " );
GetModuleBaseURL()
The GetModuleBaseURL function returns the base url of the application.
Usage
fscommand( "GetModuleBaseURL", "url" );
Parameters
url(out): Actionscript variable that receives the base url.
Returns
url
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "GetModuleBaseURL", "_root.retValue " );
Database access functions support sqlite database. Please visit http://www.sqlite.org/ to get more information about sqlite.
CreateDatabase(dbName, handle)
The CreateDatabase function creates a new sqlite database.
Usage
fscommand("CreateDatabase", "dbName, handle");
Parameters
dbName(in): the name of database.
handle(out): Actionscript variable that receives the handle of the database. A "0" value indicates an error.
Returns
handle
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "CreateDatabase", " \"test.db\", _root.retValue " );
OpenDatabase(dbName, handle)
The OpenDatabase function opens an existing database.
Usage
fscommand("OpenDatabase", "dbName, handle");
Parameters
dbName(in): the name of database.
handle(out): Actionscript variable that receives the handle of the database. A "0" value indicates an error.
Returns
handle
Sample
retValue = "";
function retValue_watch(id, oldval, newval)
{
_root.textVar = newval;
return newval;
}
_root.watch( "retValue", retValue_watch );
....fscommand( "OpenDatabase", " \"test.db\", _root.retValue " );
CloseDatabase(handle)
The CloseDatabase function close an opened database.
Usage
fscommand("CloseDatabase", " handle");
Parameters
handle(in): The handle of the database.
Returns
None.
Sample
fscommand( "CloseDatabase", _root.retValue );
ExecSQL(handle, query, value, error, message)
The ExecSQL function executes a query on the target database. The query result is in XML format. You may use XML object to decode the result string.
Usage
fscommand( "ExecSQL", "handle, query, value, error, message");
Parameters
handle(in): The handle of the database.
query(in): A string containing a valid SQL command to execute.
value(out): Actionscript variable that receives the value. The value is in XML format. The format is:
<?xml version="1.0" encoding="x"?>
<result>
<error>...</error>
<message>...</message>
<row>
<field1>...</field1><field2>...</field2>...
</row>
<row>
<field1>...</field1> <field2>...</field2>...
</row>
</result>
error(out): Actionscript variable that receives the error code.
0: Succeeds
300: Can't open the database
302: Invalid handle
303: Error in querying database.
1: Generic Error.
message(out): A string error message.
Returns
value, error, message
Sample
handle = 0;
score = 1000;
retValue ="";
textVar = "text";
queryValue = "";
errorValue = 0;
errorMessage = "";function errorMessage_watch(id, oldval, newval)
{
_root.textVar = _root.errorValue +" " + newval+ " ";
x = new XML( _root.queryValue );
//_root.textVar = x.toString();
//find the result element
elt = x.firstChild;
while( elt!=null && elt.nodeName!= "result" )
elt = elt.nextSibling;
//find the first row element
elt = elt.firstChild;
while( elt!=null && elt.nodeName!= "row" )
elt = elt.nextSibling;
//print the values
while( elt != null )
{
e = elt.firstChild;
while( e!=null )
{
_root.textVar += e.nodeName + "=" + e.firstChild.nodeValue +"\n";
e = e.nextSibling;
}
elt = elt.nextSibling;
}
return newval;
}
_root.watch( "errorMessage", errorMessage_watch );
on (press) {
sql = "\"select * from score\"";
fscommand( "ExecSQL", _root.retValue +","+ sql +", _root.queryValue, _root.errorValue, _root.errorMessage " );
}
Extract(name, retValue)
The Extract function extract a file from the packed executable file.
Usage
fscommand("Extract", "name, retValue");
Parameters
name(in): The name of the file to be extract. The folder should be added if this file is in a sub-folder.
retValue(out): Actionscript variable that receives the name of the file. Return the same name as the input name if successed. Return an empty string if failed.
Returns
retValue.
Sample
retValue = false;
function retValue_watch(id, oldval, newval)
{
if( newval!= "" )
loadMovie( newval, _root );
return newval;
}
_root.watch( "retValue", retValue_watch );...
on(press)
{
fscommand( "extract", "data\\\\test.swf, _root.retValue" );
}
DeleteExtractedFile(name)
The DeleteExtractedFile function delete an extracted file.
Usage
fscommand("DeleteExtractedFile", "name");
Parameters
name(in): The name of the file to be delete. The folder should be added if this file is in a sub-folder.
Returns
None.
Sample
fscommand( "DeleteExtractedFile", "data\\\\test.swf" );
LoadPlugin(dllName)
The LoadPlugin function loads a extension plugin dll.
Usage
fscommand("loadPlugin","dllName");
Parameters
dllName(in): Path of the extension dll.
Returns
None.
Description
The dll should implement two functions:
FLASHAPPPLUGIN_API const char** WINAPI RegisterCommand(SETVARIABLE pSetVariable);
FLASHAPPPLUGIN_API int WINAPI DoCommand( HWND hWnd, const char*cmd, const char*params,
int argc, char* argv[] );
RegisterCommand is used to register the commands implement by the plugin. pSetVariable is used to set actionscript variable when process command in DoCommand. This function returns an null terminated array of string. Each string is a name of a command. The last one should be a NULL value.
DoCommand is used to handle the command. cmd is the first parameter of the fscommand call, which represents a command name. params is the second parameter of the fscommand call. params will be split into an array of string which is the argv with delimiter ','. The argc is the length of the array.
Sample
fscommand("LoadPlugin", "plugin.dll" );