EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 387

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
fscommand() 387
Example
Usage 1: In the following example, the fscommand action sets the Flash Player to scale the SWF
file to the full monitor screen size when the button is released.
on(release){
fscommand("fullscreen", true);
}
Usage 2: The following example uses the fscommand action 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 action 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.
function myDocument_DoFSCommand(command, args) {
if (command == "messagebox") {
alert(args);
}
}
In the Flash document, add the fscommand action to a button:
fscommand("messagebox", "This is a message box called from within Flash.")
You can also use expressions for the fscommand action and parameters, as in the following
example:
fscommand("messagebox", "Hello, " + name + ", welcome to our website!")
To test the movie, choose File > Publish Preview > HTML.
Note: If you publish your SWF file using the Flash with FSCommand template in the HTML Publish
Settings, 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.

Table of Contents

Related product manuals