User Guide
190 Chapter 9: Using Flash, Flash Components, and Other Interactive Media Types
You can also use the following two sprite methods to access ActionScript variables in Flash sprites:
getVariable() and setVariable(). For more information, see the Scripting Reference topics in
the Director Help Panel.
• To return a string that contains the current value of a Flash sprite variable, use the following
statement:
spriteReference.getVariable("variableName", TRUE)
The parameter TRUE is the default, and is therefore optional.
• To return a reference to the value of a Flash variable instead of the variable’s literal value, add a
value of
FALSE to the end of the method. This lets you get or set the value of the variable
simply by using the reference.
myVariableReference = spriteReference.getVariable( "variableName", FALSE)
Once you have created the reference to the variable, you can test it with the following
statement:
put myVariableReference
-- value
• To set the current value of a Flash sprite variable to a specified string, use the following
statement:
spriteReference.setVariable( "variableName", "newValue" )
Note: Be sure to pass the Flash variable’s name and value as strings in both the getVariable()
and
setVariable() methods. Failure to do so results in script errors when the methods are
executed.
Sending messages from Flash content using getURL
A Flash sprite can send messages to Director in the form of a string by using the Flash
ActionScript
getUrl() method. The string can be an event message sent either to the scripting
engine of Director at the movie level (for example, a movie script), or at the sprite level received
only by the behavior located on the Flash sprite sending the message. The message can also be a
simple string such as "Hello Director" received by an
on getURL handler in a movie script.
In Flash, you create a button or frame and then assign it a
getURL() action in which you specify
the message you want the Flash sprite to send to Director.
The section covers the following topics:
• “Sending simple messages and script statements” on this page.
• “Sending script statements with arguments” on page 192
Sending simple messages and script statements
You can send simple strings or script statements from Flash content to a Director movie. To pass
more complicated strings, see “Sending script statements with arguments” on page 192.
To get Flash content to generate a message for Director:
1 In Flash, add the getURL function to your ActionScript code.
2 As the URL parameter of the getURL function, enter the Director script statement you want
Flash to send to the movie.