# Accessing object from array via event listener?

**URL:** <https://forum.kirupa.com/t/accessing-object-from-array-via-event-listener/306767>\
**Category:** flash\
**Created:** [March 22, 2010, 4:20am UTC](https://forum.kirupa.com/t/accessing-object-from-array-via-event-listener/306767 "2010-03-22T04:20:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmysmash](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jimmysmash](https://forum.kirupa.com/u/jimmysmash)\
**Post date:** [March 22, 2010, 4:20am UTC](https://forum.kirupa.com/t/accessing-object-from-array-via-event-listener/306767/1 "2010-03-22T04:20:58Z")

</div>

Hello,

I’m pretty new to AS3, but I have not managed to solve the following problem: basically adding instances of a bitmap on the stage (working), but then adding an event listener and knowing which is which. So for the first part:

AnArray:Array = New Array();  
AnArray[1] = New Object();  
AnArray[1].mainobject = New Makeabitmap(somedata);  
AnArray[1].mainobjectid = 1;  
addChild(AnArray[1].mainobject);  
AnArray[2] = New Object();  
AnArray[2].mainobject = New Makeabitmap(somedata);  
AnArray[2].mainobjectid = 2;  
addChild(AnArray[2].mainobject);

But if I add event listeners, how to retrieve the value of mainobjectid?

addEventListener(MouseEvent.MOUSE\_OVER,somefunction);

function somefunction(event:MouseEvent) {  
trace(event.target.name);  
}

So it will return “[Makeabitmap Object]” … but how do I fetch the objectid value from there?

Any help would be greatly appreciated !!

Cheers,

Jim.
