58
ActionScript language elements
You must add a function to the web page that contains the SWF file. This function,
myDocument_DoFSCommand()
, waits for an
fscommand()
call. When
fscommand()
is
triggered in Flash (for example, when a user clicks 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 displays the contents of the
fscommand()
function's
parameters
string.
function myDocument_DoFSCommand(command, args) {
if (command == "messagebox") {
alert(args);
}
}
In the Flash document, add
fscommand()
to a button:
fscommand("messagebox", "This is a message box called from within Flash.")
You can use expressions for the parameters of the
fscommand()
function, as shown in the
following example:
fscommand("messagebox", "Hello, " + name + ", welcome to our website!")
To test the SWF file, select File > Publish Preview > HTML. If you publish your SWF file
using the Flash with FSCommand template (in the Publish Settings dialog box, select the
HTML tag), Flash inserts the
myDocument_DoFSCommand()
function 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
.
See also
ExternalInterface (flash.external.ExternalInterface)
getProperty function
getProperty(my_mc:Object, property:Object) : Object
Returns the value of the specified property for the movie clip
my_mc
.
Availability:
ActionScript 1.0; Flash Player 4
Parameters
my_mc
:Object
- The instance name of a movie clip for which the property is being retrieved.
property
:Object
- A property of a movie clip.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...