# Help required with looping through dynamically generated clips

**URL:** <https://forum.kirupa.com/t/help-required-with-looping-through-dynamically-generated-clips/255830>\
**Category:** flash\
**Created:** [March 27, 2008, 12:38pm UTC](https://forum.kirupa.com/t/help-required-with-looping-through-dynamically-generated-clips/255830 "2008-03-27T12:38:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![uzilover](https://avatars.discourse-cdn.com/v4/letter/u/e8c25b/32.png) [@uzilover](https://forum.kirupa.com/u/uzilover)\
**Post date:** [March 27, 2008, 12:38pm UTC](https://forum.kirupa.com/t/help-required-with-looping-through-dynamically-generated-clips/255830/1 "2008-03-27T12:38:48Z")

</div>

Hi,

As part of a preloader, I’ve placed a blank movie clip on the stage and attached the following code:

```auto

onClipEvent (load) {
    for (i=0; i<50; i++) {
        ranx = Math.round(Math.random()*1000)+1;
        rany = Math.round(Math.random()*700)+1;
        var newBat:Object = attachMovie("flappingBat", "flappingBat"+i, i+1, {_x:ranx, _y:rany});
        var batArray:Array = new Array();
        batArray.push(newBat);
    }
}

onClipEvent (enterFrame) {
    for (var i = 0; i<=batArray.length-1; i++) {

        batArray*.acceleration = Math.round((Math.random()*10));
        
ranx = Math.round((Math.random()*100));
            rany = Math.round((Math.random()*100));

this.onEnterFrame = function() {
            batArray*._x += ((ranx-batArray*._x)/acceleration);
            batArray*._y += ((rany-batArray*._y)/acceleration);
            
            }
        }
    }
}

```

The bats generate fine, but I can’t get them to move about. I’ve been looking at this for hours, and just had the array idea, but I’ve missed something.

Please help.

Thanks,  
Andy
