# Adding library symbols in a for loop

**URL:** https://forum.kirupa.com/t/adding-library-symbols-in-a-for-loop/235761
**Category:** Uncategorized
**Created:** [August 14, 2007, 2:55pm UTC](https://forum.kirupa.com/t/adding-library-symbols-in-a-for-loop/235761 "2007-08-14T14:55:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![morgate](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@morgate](https://forum.kirupa.com/u/morgate)
#### Post date: [August 14, 2007, 2:55pm UTC](https://forum.kirupa.com/t/adding-library-symbols-in-a-for-loop/235761/1 "2007-08-14T14:55:55Z")

</div>

please mind the confused question, but this used to be very easy to do in AS2.  
let’s assume that i have 10 symbols in my library called \_mc0,\_mc1, \_mc2…\_mc9  
and i want to attach them dynamically to the stage

this is what I’m trying to do written in AS2

```auto

for (var i:Number=0; i<10; i++){
this["movieReference_"+i] = _root.attachMovie("_mc"+i , "newMC"+i , _root.getNextHighestDepth() );
}

```

now, when ported to AS3, the form in which we append the incremented variables to the class name looks weird (and of course it throws error 1007…  
this is the version that produces the error:

```auto

for (var i:uint=0; i<10; i++){
    var _mc = new this["_mc"+i]();
    stage.addChild(_mc)
}

```

how on earth do you rewrite the phrase \*\*var \_mc = new \_mc1() \*\*in a dynamic form?

thanks for the help in advance
