# Trouble with loops

**URL:** <https://forum.kirupa.com/t/trouble-with-loops/224669>\
**Category:** Uncategorized\
**Created:** [May 4, 2007, 10:01am UTC](https://forum.kirupa.com/t/trouble-with-loops/224669 "2007-05-04T10:01:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [May 4, 2007, 10:01am UTC](https://forum.kirupa.com/t/trouble-with-loops/224669/1 "2007-05-04T10:01:20Z")

</div>

I am having trouble using for loops to place multiple objects in various places. It always seems to just do the last one in the loop.

This is the code:

```auto
buildMenu = function(){
    _root.createEmptyMovieClip("menu_exp",getNextHighestDepth());
    for (i=0;i<urls.length;i++){
        menu_exp.attachMovie("thumb",["thumb"+i],getNextHighestDepth());
        [thumb+i]_y = i*100;
        [thumb+i]_x = 150;
    }
        menu_exp.thumb1.loadMovie(thumbs[1],getNextHighestDepth());
}

```

I’ve tried various different ways to try and get it to work and all of them just do the same thing, just make the last one in the loop. It’s as if they are all being placed in the same depth and therefore getting overwritten.

Please help!

edit: Argh I put it in the wrong actionscript forum! I’m not used to there being a separate one for AS3 yet … sorry about that.
