# onEnterFrame in a for() lopp

**URL:** <https://forum.kirupa.com/t/onenterframe-in-a-for-lopp/191286>\
**Category:** flash\
**Created:** [June 19, 2006, 12:09pm UTC](https://forum.kirupa.com/t/onenterframe-in-a-for-lopp/191286 "2006-06-19T12:09:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GNXDan](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@GNXDan](https://forum.kirupa.com/u/GNXDan)\
**Post date:** [June 19, 2006, 12:09pm UTC](https://forum.kirupa.com/t/onenterframe-in-a-for-lopp/191286/1 "2006-06-19T12:09:41Z")

</div>

Hey I have this code to go through all my movieclips and give EACH of them an onEnterFrame function.

```auto
for (var i = 0; i<menuTot; i++) {
var thumb:MovieClip = holdThumb.attachMovie("thumb", "thumb"+i,holdThumb.getNextHighestDepth());
thumb.onEnterFrame = function() {
//whatever
}
};

```

So the problem is that the only onEnterFrame function that works is the last movieclip. Obviously there is somthing wrong when defining it as it is only taking the last thumb variable for the name. How do I get it so each thumb clip gets its own onEnterFrame function?  
Thanks for your help  
Dan
