|
Executing an FSCommand action |
Top Previous Next |
|
Executing an FSCommand from your actionscript is done by calling FSCommand syntax as followed:
FSCommand("CommandName", "Parameters");
CommandName is the command you want to execute. Parameters are series of command arguments required for that particular command.
Example:
FSCommand("CopyFile", "C:\\Data\\Test.txt,C:\\Data\\Test2.txt"); This command will copy a file from C:\Data\Text.txt into C:\Data\Test2.txt
Note that FSCommand does not get executed instantly. Meaning in that example above, as soon as the actionscript is finished executing the FSCommand and moves on to the next action script command, the FSCommand CopyFile operation may not be executed yet.
In order to make sure that the command is executed fully, normally you need to set up a frame loop within your movie to wait until the FSCommand operation gives you back a return value stating that the operation is completed. This return value is passed using a global root variable "_root.FEBRetVal"
Value -1 = Cannot find an appropriate FSCommand to execute Value 0 = Operation is terminated due to an error Value 1 = Operation is completed successfully
It is advised to set the value of "_root.FEBRetVal" into -2 before executing the FSCommand so you always wait for this value to change into any of the above while waiting for the FSCommand execution.
Note that waiting in a script loop as show below will not work. As in a script loop, no FSCommand will ever be executed.
====================================================
_root.FEBRetVal = -2; FSCommand("CopyFile", "C:\\Data\\Test.txt,C:\\Data\\Test2.txt"); while (_root.FEBRetVal == -2) { }
====================================================
A correct way of setting up a frame loop is as followed:
====================================================
At frame 1 of your movie
_root.FEBRetVal = -2; FSCommand("CopyFile", "C:\\Data\\Test.txt,C:\\Data\\Test2.txt");
At frame 2 of your movie
if (_root.FEBRetVal == -2) { GotoFrame(1); }
At frame 3 of your movie
.................................
====================================================
An example FLA is also provided for your guidance in the [Application Folder]/Examples/FSCommand.FLA |