![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Use the fscommand()
function to send a message to whichever program is hosting Flash Player. The fscommand()
function has two parameters: command
and arguments
. To send a message to the stand-alone version of Flash Player, you must use predefined commands and arguments. For example, the following action sets the stand-alone player to scale the SWF file to the full monitor screen size when the button is released:
on(release){ fscommand("fullscreen", "true"); }
The following table shows the values you can specify for the command
and arguments
parameters of fscommand()
to control a SWF file playing in the stand-alone player (including projectors):
Command |
Arguments |
Purpose |
---|---|---|
quit
|
None |
Closes the projector. |
fullscreen
|
|
Specifying |
allowscale
|
|
Specifying |
showmenu
|
|
Specifying |
exec
|
Path to application |
Executes an application from within the projector. |
To use fscommand()
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 arguments
parameters. These parameters can be strings or expressions and will be used in a JavaScript function that "catches," or handles, the fscommand()
function.
An fscommand()
function invokes the JavaScript function moviename
_DoFSCommand
in the HTML page that embeds the SWF file, where moviename
is the name of Flash Player as assigned by the NAME
attribute of the EMBED
tag or the ID
attribute of the OBJECT
tag. If Flash Player is assigned the name myMovie
, the JavaScript function invoked is myMovie_DoFSCommand
.
fscommand()
to open a message box from a SWF file in the HTML page through JavaScript: function theMovie_DoFSCommand(command, args) { if (command == "messagebox") { alert(args); } }
If you publish your SWF file using the Flash with FSCommand template in the HTML Publish Settings dialog box, this code is inserted automatically. The SWF file's NAME
and ID
attributes will be the filename. For example, for the file myMovie.fla, the attributes would be set to myMovie
. (For more information about publishing, see Publishing.)
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>
fscommand()
function to a button, as shown in this example:
on(press) { fscommand("messagebox", "This is a message box invoked from within Flash."); }
You can also use expressions for fscommand()
and parameters, as in this example:
fscommand("messagebox", "Hello, " + name + ", welcome to our website!")
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.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |