...

View Full Version : var dynamic



ricmetal
12-10-2008, 08:16 PM
hey
i cant seem to get this working:

i want to trace "dang!"
AS2


imgNumb = 1;
newi = imgNumb.toString();
_root.myData.image1 = "dang!";
imageName = ["_root.myData.image" + newi];
trace(imageName);

all i get is "_root.myData.image1"

any ideas?

gnomeontherun
12-10-2008, 08:49 PM
imageName = [_root.myData.image + newi];


Well quotes turn that into a string, and not into a reference to an item. Does this work?

ricmetal
12-10-2008, 08:56 PM
it might, i just found out that tracing _root.myData.image1 yields undefined.
*what?*
any idea why this happens?
it's the only script i have on the fla

ricmetal
12-10-2008, 08:58 PM
duh, there no myData
...

ricmetal
12-10-2008, 09:01 PM
imageName = [_root.myData.image + newi];


Well quotes turn that into a string, and not into a reference to an item. Does this work?

no, that doesn't work

ricmetal
12-10-2008, 09:08 PM
got it :)

imgNumb = 1;
newi = imgNumb.toString();
_root.myData.image1 = "dang!";
imageName = eval("_root.myData.image" + newi);
trace(imageName);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum