# creatEmptyMovieClip() with onRelease() function via a loop

**URL:** <https://forum.kirupa.com/t/createmptymovieclip-with-onrelease-function-via-a-loop/297728>\
**Category:** flash\
**Created:** [October 7, 2009, 5:38pm UTC](https://forum.kirupa.com/t/createmptymovieclip-with-onrelease-function-via-a-loop/297728 "2009-10-07T17:38:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![savagestudio](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@savagestudio](https://forum.kirupa.com/u/savagestudio)\
**Post date:** [October 7, 2009, 5:38pm UTC](https://forum.kirupa.com/t/createmptymovieclip-with-onrelease-function-via-a-loop/297728/1 "2009-10-07T17:38:46Z")

</div>

Hello evryone, Im not a pro in Action script but  
I’m trying to display thumbnails with a for loop but i would like that each thumbnail have an onrelease action. Do somebody can Help me ??? i did 3 forum and no answers.

here is my script:(note: i use trace() for look if my loop works aswith the onrelease function)

```auto
var posX = 163;//1st position 
var posY = 103;//1st position 
var Dec = 0;// var for the space between thumbnails set to 0 

for (i=0; i<5; i++) { 
var Num = i+1; 
var Clp_name = "clip"+Num; 
var container = (container+Num); 
var container:MovieClip = this.createEmptyMovieClip(Clp_name, this.getNextHighestDepth()); 
container.loadMovie("images/images.jpg",this.getNextHighestDepth()); 
container._x = posX; 
container._y = posY+Dec; 

this.Clp_name.onRelease = function() { 
WhoIsOn = i-1; 
trace(WhoIsOn); 

}; 
trace(Clp_name); 
Dec = Dec+40;// increment the space between thumbnail 
} 

```

I also tryed:

```auto
this[Clp_name].onRelease = function() { 
WhoIsOn = i-1; 
trace(WhoIsOn); 

```

and

```auto
this.container[Clp_name].onRelease = function() { 
WhoIsOn = i-1; 
trace(WhoIsOn); 

```
