|
Writing your own FSCommand |
Top Previous Next |
|
Flash EXE Builder allows you to extend the capability of the built-in FSCommands by writing your own using a Visual C++ 6.0 or .NET. Visual Basic DLL should also work although it has not been tested.
To make one, you need to package your FSCommands into a DLL and put the DLL in the [Application Folder]/FSCommandDLL folder. Every DLLs put in this folder will be packaged with the published application (given that the publish setting is to include FSCommand DLLs).
An FSCommand DLL must export two important API functions:
1. InitFSCommand
Syntax FSCOMMANDDLL_API int InitFSCommand(HWND hwnd, char* workspacePath);
Description To initialize the FSCommand DLL. Put all the initialization code here
Parameters hwnd = Handle to the parent application window workspacePath = The workspace folder where the application resources (additional files and play list files) are extracted
Return 1 = success 0 = failed
2. DoFSCommand
Syntax FSCOMMANDDLL_API int DoFSCommand(char* name, char* param, char* outParam);
Description This API will be called whenever an FSCommand occured. You must check whether an FSCommand name is belong to yours and if so, do the appropriate action.
Parameters name = The name of the FSCommand action currently executed param = The FScommand parameters currently executed outParam = You need to output the output parameters here.
Return 1 = success 0 = failed -1 = FSCommands cannot be found
Example
A call to FSCommand("GetFileSize", "C:\\Test.dat,RetSizeVar") will initiate a call to API DoFSCommand("GetFileSize", "C:\\Test.dat,RetSizeVar", outParam);
An action performed by the FSCommand DLL to get the file size of C:\Test.dat. The return value will be passed in an outParam parameters as followed "RetSizeVar=6000". Note that RetSizeVar name is used as the FSCommand caller requested to use RetSizeVar as a return value.
Flash EXE Builder main application will receive the outParam and set the appropriate Flash movie variable value _root.RetSizeVar into 6000.
Some FSCommand might need to return more than one parameters. In this case, separate each parameter with a comma.
Example
outParams = "DesktopWidthVar=500,DesktopHeightVar=200"
You can use a character ~ (tilda) as an escape sequence, in case you need to include a comma in one of your string parameter.
Example
outParams = "MessageVar=John~,Ryan and Smith,AnswerVar=5"
|