↑
Main Page
Eframe
Using
SetVariable()
and
GetVariable()
, it’s possible to pass information to and get information
from a Flash movie. For this to work, the Flash movie must have a variable that is watched for a value
change. The simplest way to do this is to create a text field and tie its value to a variable (by selecting
Dynamic Text from the Flash Properties panel and entering the name of the variable). Then, you can get
the value of the variable using
GetVariable()
and change its value using
SetVariable()
. Both meth-
ods require the name of the variable in relation to its timeline. So, to access a variable named
message
in the main timeline, the first argument for both methods is
“/:message”
, where
“/”
represents the
default timeline, the colon indicates a part of the timeline to access, and
message
is the variable name.
For example:
var sOriginalMessage = oFlashMovie.GetVariable(“/:message”);
oFlashMovie.SetVariable(“/:message”, “my new message”);
Some methods also work on a specific timeline in the movie:
?
TCallFrame(timeline, frame_number)
— Executes the action in the Eframe that is in the
given position
?
TCallLabel(timeline, frame_label)
— Executes the action in the frame represented by
the given label
?
TCurrentFrame(timeline)
— Returns the position of the current frame in the timeline
?
TCurrentLabel(timeline)
— Returns the label of the current frame in the timeline
?
TGetProperty(timeline, property_constant)
— Returns the value of the property indi-
cated by the property constant (discussed later) as a string
?
TGetPropertyAsNumber(timeline, property_constant)
— Returns the value of the
property indicated by the property constant as a number
?
TGotoFrame(timeline, frame_number)
— Sets the movie to the frame in the given position
in the timeline
?
TGotoLabel(timeline, frame_label)
— Sets the movie to the frame with the given label
in the timeline
?
TPlay(timeline)
— Plays the movie on the given timeline
?
TSetProperty(timeline, property_constant, value)
— Sets the value of the property
indicated by the property constant as a string
?
TStopPlay(timeline)
— Stops the movie on the given timeline
The
TGetProperty()
,
TGetPropertyAsNumber()
, and
TSetProperty()
methods all use constants to
indicate the property to get or set. Because the constants are only accessible from within Flash, JavaScript
must always use the numeric value. The constants are listed in the following table:
Flash Constant
Value
Description
X_POS
0
The x-coordinate of the movie
Y_POS
1
The y-coordinate of the movie
X_SCALE
2
Horizontal scaling
554
Chapter 18
21_579088 ch18.qxd 3/28/05 11:43 AM Page 554
Free JavaScript Editor
Ajax Editor
©
→