# Getting Prosperities of Dynamic Objects

**URL:** <https://forum.kirupa.com/t/getting-prosperities-of-dynamic-objects/294433>\
**Category:** flash\
**Created:** [August 13, 2009, 9:41pm UTC](https://forum.kirupa.com/t/getting-prosperities-of-dynamic-objects/294433 "2009-08-13T21:41:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesseclark](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jesseclark](https://forum.kirupa.com/u/jesseclark)\
**Post date:** [August 13, 2009, 9:41pm UTC](https://forum.kirupa.com/t/getting-prosperities-of-dynamic-objects/294433/1 "2009-08-13T21:41:37Z")

</div>

I am looping through and creating a random number of dynamic objects. I am trying to create an click addEventListener that will trace the name property of the object being clicked. Here is my script:

```auto
 
var xSpacing:int = new int;
var textArray:Array = new Array;
 
for (var i:int = 1; i < 10; i++){ 
 textArray* = new TextField;
 with(textArray*){
  text = i;
  height = 20;
  width = 20;
  x = xSpacing;
  y = 0;
  name = "box" + i;   
 }
 
 addChild(textArray*);
 textArray*.addEventListener(MouseEvent.CLICK, function(event){ numberClicked(textArray*); });
 
 xSpacing=xSpacing+50;
}
public function numberClicked(o:Object){
 trace(o.name);   
}

```

When clicked the it tries to trace the next object (object 11) instead of tracing the one being clicked. How do I make the addEventListener unique to each instance?

Thanks
