User Guide
Sending messages to and from Flash Player 287
7.
In an HTML or text editor, open the HTML file that was generated in step 6 and examine the
code. When you published your SWF file using the Flash with FSCommand template on the
HTML tab of the Publish Settings dialog box, some additional code was inserted in the HTML
file. The SWF file’s
NAME and ID attributes are the filename. For example, for the file
myMovie.fla, the attributes would be set to
myMovie.
8.
In the HTML file, add the following JavaScript code where the document says // Place your
code here.
:
if (command == "alert") {
alert(args);
}
else if (command == "popup") {
window.open(args, "mmwin", "width=500,height=300");
}
Alternatively, for Microsoft Internet Explorer applications, you can attach an event handler
directly in the
<SCRIPT> tag, as shown in this example:
<Script Language = "JavaScript" event="FSCommand (command, args)" for=
"theMovie">
...
</Script>
9.
Save and close the HTML file.
When you’re editing HTML files outside of Flash in this way, remember that you must
deselect the HTML check box in File > Publish Settings, or your HTML code will be
overwritten by Flash when you republish.
10.
In a web browser, open the HTML file to view it. Click the Open Window button; a window
opens to the Macromedia website. Click the Alert button; an alert window opens.
The
fscommand() function can send messages to Macromedia Director that are interpreted by
Lingo as strings, events, or executable Lingo code. If the message is a string or an event, you must
write the Lingo code to receive it 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.
In Visual Basic, Visual C++, and other programs that can host ActiveX controls,
fscommand()
sends a VB event with two strings that can be handled in the environment’s programming
language. For more information, use the keywords Flash method to search the Flash Support
Center at www.macromedia.com/support/flash.
About Flash Player methods
You can use Flash Player methods to control a SWF file in Flash Player from web-browser
scripting languages such as JavaScript and VBScript. As with other methods, you can use Flash
Player methods to send calls to SWF files from a scripting environment other than ActionScript.
Each method has a name, and most methods take parameters. A parameter specifies a value upon
which the method operates. The calculation performed by some methods returns a value that can
be used by the scripting environment.