# Referencing multiple classes in a for loop

**URL:** https://forum.kirupa.com/t/referencing-multiple-classes-in-a-for-loop/279294
**Category:** flash
**Created:** [January 12, 2009, 11:58pm UTC](https://forum.kirupa.com/t/referencing-multiple-classes-in-a-for-loop/279294 "2009-01-12T23:58:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![flashdaddy](https://avatars.discourse-cdn.com/v4/letter/f/e36b37/32.png) [@flashdaddy](https://forum.kirupa.com/u/flashdaddy)
#### Post date: [January 12, 2009, 11:58pm UTC](https://forum.kirupa.com/t/referencing-multiple-classes-in-a-for-loop/279294/1 "2009-01-12T23:58:28Z")

</div>

Hi All,

I have an issue here that has me stumped. I’m trying to reference multiple classes in my for loop:

```auto

    for(var a:Number = 0; a < 5; a++){
    var img[a]:Img[a] = new Img[a]();
    addChild(img[a])
}

```

I have 5 images I’m trying to add to the stage, but when I run the above code, I get the following error:

```auto
1086: Syntax error: expecting semicolon before leftbracket.

```

However, when I run the following trace:

```auto
trace("img" + [a])

```

I see the desired result. I’ve tried multiple combinations but nothing has worked for me yet. Any ideas?
