Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : diference between eval and []


marcelozep
4/12/2004 8:58:33 PM
what is the diference between eval and []?
like this
x="trace"
eval(x)("OK")
returns "ok"
[x]("OK")
EgyptianBrain
4/12/2004 11:21:15 PM
i guess there are no difference between them ... the concept is that what do
you want to do , here are some examples on eval and on [ ] , i hope it helps
and please post me another message if u still have problems thanks a lot

piece3 = "dangerous";
x = 3;

y = eval("piece" + x); // the name of the variable is expression so you must
use eval got it ?
trace(y);

// Output: dangerous


and about [ ]

if you want assign properties to a movie clip and its name is expression too
you may use [ ] here is an example

// there is a movie clip on the stage with instance name mc1
i=1;
_root["mc"+i]._x = 100;

// you may use this in for loops or something based on ur demands

enjoy
AddThis Social Bookmark Button