I’m learning Actionscript and I’m kind of stuck on for loop.
I have this code ,
movieClip.thumbnail1.addEventListener(MouseEvent.CLICK ,myBtn1);
function myBtn1(evt:MouseEvent):void
{
var myMC:MC1 = new MC1();
mcPlacement.addChild(myMC);
}
movieClip.thumbnail2.addEventListener(MouseEvent.CLICK ,myBtn2);
function myBtn2(evt:MouseEvent):void
{
var myMC2:MC2 = new MC2();
mcPlacement.addChild(myMC2);
}
and I am wondering, how do you use for loop to stack them up so that I can run over 10 buttons without having to type the long way, should I make use of arrays as well?
If movieClip contains only the thumbNails that you want to add event listeners for then you can do :
If you know the names of the thumbnails before hand you can create different movie clips inside the event handler and add them to mcPlacement.