Académique Documents
Professionnel Documents
Culture Documents
ActionScript
for Flash MX
Pocket Reference
Colin Moock
ActionScript for Flash MX
Pocket Reference
Colin Moock
Timeline Variables
Timeline variables are variables declared with the var state-
ment on a frame of a timeline, or in a button’s on( ) handler
or a movie clip’s onClipEvent( ) handler. Once defined, time-
line variables are accessible directly from any other frame on
the same timeline, and indirectly via dot syntax from other
movie clip timelines. For example:
// Declare timeline variable length
var length = 10;
Variables | 13
Note, however, that if movie1.swf is loaded into a movie clip
in movie2.swf, the _root property in movie1.swf refers to the
main timeline of movie2.swf! To create an unchanging refer-
ence to a movie’s main timeline, add the following code to
frame 1 of the main timeline, substituting your movie’s name
for movieName:
_global.movieNameMainTimeline = this;
Global Variables
Global variables are accessible from any timeline throughout
any movie currently loaded into the Flash Player. To create a
global variable, or to assign a global variable a new value,
use:
_global.varName = value;
Code Hinting
Table 3 lists the variable name suffixes that cause the Actions
panel to display a quick-reference pop-up (so-called code
hinting) when the variable name is entered. For example, to
enable code hinting for a text field variable, you can name
the variable output_txt.
Variables | 15
Table 3. Code-hinting suffixes (continued)
Suffix Datatype or class represented
_sound Sound
_xml XML
_xmlsocket XMLSocket
_color Color
_video Video
_ch FCheckBox
_pb FPushButton
_rb FRadioButton
_lb FListBox
_sb FScrollBar
_cb FComboBox
_sp FScrollPane