I have about 20 clips generated randomly, and they are stored in an array.
I create a for statement that cycles through the clips and adds random properties.
To add event listeners to each clip that I cycle through, how do I get around this:
var clipData:Array=new Array;
clipData['clip01'] = ({lbl: 'clip01', url: 'swf/clip01.swf'});
clipData['clip02] = ({lbl: 'clip02', url: 'swf/clip02.swf'});
for (var clipIndex:String in clipArr) {
... code for adding properties here ...
... event listener part ...
if (clipIndex == 'clip01'){clipData[clipIndex].addEventListener(MouseEvent.MOUSE_OVER, overHandler1);}
if (clipIndex == 'clip02'){clipData[clipIndex].addEventListener(MouseEvent.MOUSE_OVER, overHandler2);}
}
function overHandler1(e:Event):void{ overHandler(1); }
function overHandler2(e:Event):void{ overHandler(2); }
function overHandler(clipIndex:String):void{
trace(clipData[clipIndex]['lbl']);
}
Thew above works, but when I have 20 event handler functions for the same thing, it get s reduntant.
Plus the amount of clips may change dynamically depending on user input… any way around this?