# Dynamic MovieClip Events

**URL:** <https://forum.kirupa.com/t/dynamic-movieclip-events/268660>\
**Category:** flash\
**Created:** [August 16, 2008, 10:26pm UTC](https://forum.kirupa.com/t/dynamic-movieclip-events/268660 "2008-08-16T22:26:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tokyoboy](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@tokyoboy](https://forum.kirupa.com/u/tokyoboy)\
**Post date:** [August 16, 2008, 10:26pm UTC](https://forum.kirupa.com/t/dynamic-movieclip-events/268660/1 "2008-08-16T22:26:44Z")

</div>

Hi all,

I’ve been trying to create a vertical navigation bar. Each button on the bar is dynamically created by the fadeRecsIn() function. Each button is also populated with a text field that populates from the Array of strings “t”.

I need to be able to make each button do something different upon being clicked on. I think my code below explains it pretty well.

var clips:Array = new Array();

function fadeRecsIn() {  
for (var i:uint; i\<t.length; i++) {  
var br:BlueRec = new BlueRec();  
var tf:TextField = new TextField();  
tf.text = t\*;  
br.x = 0;  
br.y = i_53;  
//Fade buttons in and down  
var brtween:Tween = new Tween(br,“alpha”,Regular.easeIn,0,1,1,true);  
var brYtween:Tween = new Tween(br,“y”,Regular.easeIn,br.y-100,i_53,1,true);  
//add br Movieclip to stage  
br.addChild(tf);  
//set buttonMode to true  
br.buttonMode = true;  
//populate clips array with new movieclip instance  
clips.push(br);  
addChild(br);  
}  
}  
//call function  
fadeRecsIn();

//assign event listener for MOUSE\_UP to each instance in the clips array.  
for (var i:uint=0; i\<clips.length; i++) {  
clips\*.addEventListener(MouseEvent.MOUSE\_UP,onReleaseHandler);  
}

function onReleaseHandler(e:MouseEvent) {  
//I think this is where the problem is.  
//move the movieclip that was clicked on 20 pixels to right.  
this.x += 20  
}

Let me know if you need any more information and thanks very much for your time!!!
