User Guide
fscommand() 307
function myDocument_DoFSCommand(command, args) {
if (command == "messagebox") {
alert(args);
}
}
In the Flash document, add the fscommand() function to a button:
fscommand("messagebox", "This is a message box called from within Flash.")
You can also use expressions for the fscommand() function and parameters, as in the
following example:
fscommand("messagebox", "Hello, " + name + ", welcome to our website!")
To test the SWF file, select File > Publish Preview > HTML.
Note: If you publish your SWF file using the Flash with FSCommand template in the HTML tab of the
Publish Settings dialog box, the
myDocument_DoFSCommand function is inserted automatically. The
SWF file’s
NAME and ID attributes will be the filename. For example, for the file myDocument.fla, the
attributes would be set to
myDocument.