User Guide

306 Chapter 2: ActionScript Language Reference
The exec command can contain only the characters A–Z, a–z, 0–9, period (.), and underscore
(_). The
exec command runs in the subdirectory fscommand only. In other words, if you use the
fscommand exec command to call an application, the application must reside in a subdirectory
named fscommand.
Usage 2: To use the
fscommand() function to send a message to a scripting language such as
JavaScript in a web browser, you can pass any two parameters in the
command and parameters
parameters. These parameters can be strings or expressions and are used in a JavaScript function
that handles, or catches, the
fscommand() function.
In a web browser, the
fscommand() function calls the JavaScript function
moviename_DoFScommand in the HTML page containing the SWF file. The moviename is the
name of the Flash Player as assigned by the
NAME attribute of the EMBED tag or the ID property of
the
OBJECT tag. If you assign the Flash Player the name myDocument, the JavaScript function
called is
myDocument_DoFScommand.
Usage 3: The
fscommand() function can send messages to Macromedia Director that are
interpreted by Lingo (Directors scripting language) as strings, events, or executable Lingo code. If
the message is a string or an event, you must write the Lingo code to receive the message from the
fscommand() function and carry out an action in Director. For more information, see the
Director Support Center at www.macromedia.com/support/director.
Usage 4: In Visual Basic, Visual C++, and other programs that can host ActiveX controls, the
fscommand() function sends a VB event with two strings that can be handled in
the environments programming language. For more information, use the keywords Flash method
to search the Flash Support Center at www.macromedia.com/support/flash.
Example
In the following example, the fscommand() function sets Flash Player to scale the SWF file to the
full monitor screen size when the
fullscreen_btn button or unfullscreen_btn is released:
this.fullscreen_btn.onRelease = function() {
fscommand("fullscreen", true);
};
this.unfullscreen_btn.onRelease = function() {
fscommand("fullscreen", false);
};
The following example uses the fscommand() function applied to a button in Flash to open a
JavaScript message box in an HTML page. The message itself is sent to JavaScript as the
fscommand parameter.
You must add a function to the HTML page that contains the SWF file. This function,
myDocument_DoFSCommand, sits in the HTML page and waits for an fscommand() function in
Flash. When an
fscommand is triggered in Flash (for example, when a user presses the button), the
command and parameter strings are passed to the myDocument_DoFSCommand function. You can
use the passed strings in your JavaScript or VBScript code in any way you like. In this example,
the function contains a conditional
if statement that checks to see if the command string is
"messagebox". If it is, a JavaScript alert box (or “message box”) opens and displays the contents
of the
parameters string.