# For-statement working too fast!

**URL:** <https://forum.kirupa.com/t/for-statement-working-too-fast/284287>\
**Category:** Uncategorized\
**Created:** [March 17, 2009, 4:19pm UTC](https://forum.kirupa.com/t/for-statement-working-too-fast/284287 "2009-03-17T16:19:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alva](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/alva/32/7449_2.png) [@alva](https://forum.kirupa.com/u/alva)\
**Post date:** [March 17, 2009, 4:19pm UTC](https://forum.kirupa.com/t/for-statement-working-too-fast/284287/1 "2009-03-17T16:19:32Z")

</div>

I’m using a for-statement to add a series of movieclips.

for (var i:Number = 0; i\<10; i++) {  
attachMovie(“myMC”, “myMC”+i, this.getNextHighestDepth());  
}

Inside the movieclips I have some code. In this code I need the index-number of the movieclip. I’m staring the code off with:

var indexr:Number = \_root.i;

The for-statement is so fast that all the movieclips get number 9 in the index-variable!

Is there any trick to manage this, like can I get the index from the name in some way? Or do I have to work around it in some more or less complicated way?

It is important that the movieclip knows what index it has.
