MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 122

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

Example
The following example shows two ways to create a new empty Array object; the first line uses
brackets ([]):
var my_array:Array = [];
var my_array:Array = new Array();
The following example creates an array called
to send the elements to the Output panel. In the fourth line, an element in the array is
changed, and the fifth line sends the newly modified array to the Output panel:
var employee_array = ["Barbara", "George", "Mary"];
trace(employee_array); // output: Barbara,George,Mary
employee_array[2] = "Sam";
trace(employee_array); // output: Barbara,George,Sam
In the following example, the expression inside the brackets (
the result is used as the name of the variable to be retrieved from the
example, the variable
to 5, for example, the value of the variable
Output panel:
myBtn_btn.onRelease = function() {
x = my_mc["piece"+i];
trace(x);
};
In the following example, the expression inside the brackets is evaluated, and the result is used
as the name of the variable to be retrieved from movie clip
name_mc["A" + i];
If you are familiar with the Flash 4 ActionScript slash syntax, you can use the
function to accomplish the same result:
eval("name_mc.A" & i);
You can use the following ActionScript to loop over all objects in the
useful for debugging:
for (i in _root) {
trace(i+": "+_root[i]);
}
You can also use the array access ([]) operator on the left side of an assignment statement to
dynamically set instance, variable, and object names:
employee_array[2] = "Sam";
See also
,
,
Array
Object
eval function
122
ActionScript language elements
must live on the same Timeline as the button. If the variable
i
employee_array
"piece" + i
in the
piece5
my_mc
name_mc
and uses the trace() statement
) is evaluated and
movie clip. In this
my_mc
i
movie clip is displayed in the
:
eval()
scope, which is
_root
is equal

Advertisement

Table of Contents
loading

Table of Contents