PDA

View Full Version : referencing movie clips in a for loop



potamus
July 16th, 2003, 07:53 PM
I want to have 4 to n movie clips on my stage and to be be able perform monotonous operations on all of them in a for loop like so.

for(i=0;i<numClips;i++)
{
if(this.hitTest("clip"+i))
trace("hit!");
else
trace("no hit");
}

as you can see I've labeled my clips clip1, clip2, clip3... but it won't let me reference the clip using an expression "clip"+i

If i hard code it in like this...

if(this.hitTest("clip1"))
trace("hit!");
else if(this.hitTest("clip2"))
trace("hit!");
else
trace("no hit");

then it will work.

Any help would be greatly appreciated. thanks.

kode
July 16th, 2003, 08:00 PM
Welcome to kirupa forum, potamus. =)

Funny... I just posted this link in another thread. :P
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082

potamus
July 16th, 2003, 08:11 PM
problem solved!

kode
July 16th, 2003, 08:13 PM
No problem. ;)