# Dynamic object creation

**URL:** <https://forum.kirupa.com/t/dynamic-object-creation/271880>\
**Category:** Uncategorized\
**Created:** [September 30, 2008, 12:38am UTC](https://forum.kirupa.com/t/dynamic-object-creation/271880 "2008-09-30T00:38:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zbmarley](https://avatars.discourse-cdn.com/v4/letter/z/a4c791/32.png) [@zbmarley](https://forum.kirupa.com/u/zbmarley)\
**Post date:** [September 30, 2008, 12:38am UTC](https://forum.kirupa.com/t/dynamic-object-creation/271880/1 "2008-09-30T00:38:32Z")

</div>

ive read about this prob several places and cant seem to find an answer so here is what i got, i want to have a certain number of what im calling buttons but could be anything created dynamically here is how i did it,

public function tweener3():void{

```
for (var i=1;i&lt;num_of_btns;i++){
test* = ["mc"+i];
x_pos += 150;
make_btns(test*, x_pos, y_pos, i);
}
}//end constructor

```

that works, then for the make\_btns i wrote this

```
public function make_btns(names3, x_pos, y_pos, num)
{
trace(names3);
var btns = new Array;
var names3 = new air2();
names3.x = x_pos;
names3.y = y_pos;
names3.addEventListener(MouseEvent.CLICK, onClick);
names3.is_active = false;
this.addChild(names3);
btns[num]=names3;
trace(btns[num].is_active);
//}
}

```

And this works, then when you click i had to do a few work arounds to make only one move by testing target, but how would i go about knowing if any of the buttons are in the active state?

here is what i tried, but not working, i need a way to access the properties for the seperate buttons on the stage, but i have tried every which way of refrencing them,

function onClick(event:MouseEvent):void  
{  
trace (‘test1 is’ + test[1]);

var target\_clip2:MovieClip = MovieClip(test[1]);  
trace(target\_clip2.is\_active)  
var stage\_height = stage.stageHeight/2;  
var target\_clip:MovieClip = MovieClip(event.targe  
if(target\_clip.is\_active == false){  
target\_clip.is\_active = true;  
Tweener.addTween(target\_clip,{x:stage.stageWidth/2, y:stage.stageHeight/2, width:200, height:200, time:1});  
}  
else{  
target\_clip.is\_active = false;  
Tweener.addTween(target\_clip,{x:50, y:40, width:200, height:200, time:1}  
}}  
does anyone know how i would do this? i can use mc1 mc2 … to get the properties, i would think i could but it might be because of how im using the  
test\* = [“mc”+i];  
any ideas would be much appreciated thanks,
