
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.
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...