Using variables
To specify a variable on a timeline, use slash syntax (/) combined with dots (..) and colons (:).
You can also use the dot notation.
The following code refers to the
/:car
_root.car
The following example shows the
main timeline:
/mc1/mc2/:car
_root.mc1.mc2.car
The following example shows the
current timeline:
mc2/:car
mc2.car
Emulating arrays
Arrays are useful for creating and manipulating ordered lists of information such as variables
and values. However, Flash Lite 1.1 does not support native array data structures. A common
technique in Flash Lite (and Flash 4) programming is to emulate arrays with string processing.
An emulated array is also called a pseudo-array. The key to pseudo-array processing is the
ActionScript function, which lets you access variables, properties, or movie clips by
eval()
name. For more information, see
A pseudo-array typically consists of two or more variables that share the same base name,
followed by a numeric suffix. The suffix is the index for each array element.
For example, suppose you create the following ActionScript variables:
color_1 = "orange";
color_2 = "green";
color_3 = "blue";
color_4 = "red";
You can then use the following code to loop over the elements in the pseudo-array:
for (i = 1; i <=4; i++) {
trace (eval ("color_" add i));
}
variable on the main timeline:
car
variable in a movie clip instance that resides on the
car
variable in a movie clip instance that resides on the
car
"Using the eval() function" on page
17.
Emulating arrays
11
Need help?
Do you have a question about the FLASH 8-LEARNING FLASH LITE 1.X ACTIONSCRIPT and is the answer not in the manual?