Eval() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

eval()

Availability
Flash Player 5 or later for full functionality. You can use the
Flash Player 4, but you must use slash notation and can access only variables, not properties
or objects.
Usage
eval(expression:String) : Object
Parameters
A string containing the name of a variable, property, object, or movie clip
expression
to retrieve.
Returns
A value, reference to an object or movie clip, or
Description
Function; accesses variables, properties, objects, or movie clips by name. If
variable or a property, the value of the variable or property is returned. If
or movie clip, a reference to the object or movie clip is returned. If the element named in
cannot be found,
expression
In Flash 4,
eval()
to simulate arrays.
In Flash 4, you can also use
instance name. However, you can also do this with the array access operator (
In Flash 5 or later, you cannot use
instance name, because you cannot use
replace the code
eval ("var" + i) = "first";
with this:
this["var"+i] = "first"
or this:
set ("var" + i, "first");
Example
The following example uses
ActionScript sets the
and
square3_mc
for (var i = 1; i<=3; i++) {
setProperty(eval("square"+i+"_mc"), _rotation, 5);
}
undefined
was used to simulate arrays; in Flash 5 or later, you should use the Array class
to dynamically set and retrieve the value of a variable or
eval()
eval()
to set properties for dynamically named movie clips. This
eval()
property for three movie clips, called
_rotation
.
ActionScript Language Reference
eval()
.
undefined
is returned.
to dynamically set and retrieve the value of a variable or
on the left side of an equation. For example,
eval()
CHAPTER 2
function when exporting to
is a
expression
is an object
expression
).
[]
,
square1_mc
square2_mc
eval()
,
295

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents