# Multiple dynamic movieclips

**URL:** <https://forum.kirupa.com/t/multiple-dynamic-movieclips/308853>\
**Category:** Uncategorized\
**Created:** [May 1, 2010, 7:44pm UTC](https://forum.kirupa.com/t/multiple-dynamic-movieclips/308853 "2010-05-01T19:44:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanzochan](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@sanzochan](https://forum.kirupa.com/u/sanzochan)\
**Post date:** [May 1, 2010, 7:44pm UTC](https://forum.kirupa.com/t/multiple-dynamic-movieclips/308853/1 "2010-05-01T19:44:48Z")

</div>

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:

```auto

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:

```auto

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:

```auto

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?
