On the stage I have a three kind of movieclips
Few static movieclips whose name is: mc1; mc2; mc3…. them are visible on stage
Few static movielips" othermc1; othermc2l othermc3… and them have "visible = false"
One movieclip whose is moving on the stage and his name is "slider"
I have function when mc "slider" intersects one of the rest of mc1, mc2… to turn visible othermc1, othermc2
var alreadyHandled:Boolean = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
{
if(mc1.getRect(this).intersects(slider.getRect(this)))
{
if(!alreadyHandled)
{
show1();
alreadyHandled = true;
}
}
else
{
alreadyHandled = false;
no1();
}
function show1():void
{
othermc1.visible = true;
}
function no1():void
{
othermc2.visible = false;
}
How can i use this code in loop?
Thanks for help
Best Answer
If you want loop through mc1, mc2, mc3,... create an
Array
ofMovieClip
s:Then use
for
to iterate over the array elements:This code may help you: