Question

I have set a boolean value:

austria_clicked = false;

I want to access this value and change it through eval function, because the country name will change in "for" cycle.

eval( country + "_clicked") = true;

But this isn't working, it's giving me this compiling error:

Symbol=Interactive map, layer=actions_mouse, frame=1, Line 63   Left side of assignment operator must be variable or property.

Any ideas?

Was it helpful?

Solution

Try using the Array access operator []:

 this[country + "_clicked"] = true;

There are some other alternatives as well (old method from Flash 4 apparently):

 set(country + "_clicked", true);

Or, don't use eval() on the left side of the assignment operator (=), this was probably added for security reasons:

 var foo = eval(country + "_clicked"); // eval() is used on the right!
 foo = true;

I've never programmed in AS2 (only AS3), so hope this helps. It's explained very nicely in this blog post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top