Hi guys. I’m having a rather big problem with my codes. I’m trying to load the images into different dynamically made movieclips using a for loop.
Here’s the code:
for (var i:int=0; i<presArray.length; i++) {
var imageName:String = presArray*;
var image = loadImage(imageName);
var mc = new MovieClip();
mc.x = (picWidth + 15) * i;
mc.name = imageName;
mc.addChild(image);
container_mc.addChild(mc);
}
It works fine if I’m just loading the images onto the stage, but if I want to refer to the movieclips in other functions such as this:
function hitTestPic(e:Event):void {
if (container_mc.hitTestObject(catcher_mc)) {
trace("hit.");
trace(mc.name);
}
}
it gives me an error that says undefined property of mc. I then tried to manually name the MCs mc0, mc1, mc2 and so on, I tried calling them in the for loop like this:
for (var i:int=0; i<presArray.length; i++) {
var imageName:String = presArray*;
var image = loadImage(imageName);
var mc* = new MovieClip();
mc*.x = (picWidth + 15) * i;
mc*.name = imageName;
mc*.addChild(image);
container_mc.addChild(mc*);
}
it gives me the error “1086: Syntax error: expecting semicolon before leftbracket. (at) var mc*:MovieClip = new MovieClip();”[COLOR=Black][COLOR=#800000][FONT=Segoe UI][/FONT][/COLOR][/COLOR] I’m thinking it’s because of the mc*, because if I comment the rest out and remove the * from the mc, it works fine.
Can anyone help please?