PDA

View Full Version : use variable instead of instance name



alipica
October 5th, 2009, 10:25 PM
I'm hoping this will be an easy question to answer. Basically, I'm trying to loop through my sub menu buttons to see if they're on a certain frame.

My question deals with an if statement inside a for loop:

if (MovieClip(root).subMenu1.currentFrame == "16") {
MovieClip(root).subMenu1.gotoAndStop("out");
}

Is it possible to replace the instance name (subMenu1) with a variable? I tried just replacing it but that didn't work. I also tried adding plus signs around it and that didn't work either.

Obviously, I'm new to actionscript. Sorry for the stupid question =S

Thanks for any answers in advance!

TheCanadian
October 5th, 2009, 10:34 PM
subMenu1 is a variable. Afraid I don't follow what you're trying to do :)

Krilnon
October 5th, 2009, 10:42 PM
I'm guessing alipica wants to do:



for(i < somestuff, etc.){
MovieClip(root)['subMenu' + i].currentFrame == '16' ? okay, great, or that sucks
}

…just because that's what most people ask.

TheCanadian
October 6th, 2009, 02:46 AM
Haha of course, it's been a while.