Using the eval() function
The
function lets you dynamically reference variables and movie clip instances at
eval()
runtime. The
eval()
value of the variable represented by that expression or a reference to a movie clip.
For example, the following code evaluates the value of the
assigns the result to
nameValue
name = "Jack";
nameValue = eval("name");
// result: nameValue = "Jack"
The
function is often used with
eval()
operator to create string-based arrays, because Flash Lite doesn't support native array data
structures. For more information, see
You can also use
eval()
had three movie clips named
the x position of each clip by 10 pixels:
for(index = 1; index <= 3; index++) {
eval("clip" add index)._x += 10
}
function takes a string expression as a parameter and returns either the
:
for()
"Emulating arrays" on page
to reference movie clip instances by name. For example, suppose you
,
, and
clip1
clip2
ActionScript variable and
name
loops and the
(string concatenation)
add
11.
. The following
clip3
Using the eval() function
loop increments
for()
17
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?
Questions and answers