# Mouse Events having problems?

**URL:** <https://forum.kirupa.com/t/mouse-events-having-problems/250599>\
**Category:** flash\
**Created:** [January 30, 2008, 10:20pm UTC](https://forum.kirupa.com/t/mouse-events-having-problems/250599 "2008-01-30T22:20:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xohol](https://avatars.discourse-cdn.com/v4/letter/x/59ef9b/32.png) [@xohol](https://forum.kirupa.com/u/xohol)\
**Post date:** [January 30, 2008, 10:20pm UTC](https://forum.kirupa.com/t/mouse-events-having-problems/250599/1 "2008-01-30T22:20:20Z")

</div>

Hello,  
Im trying to get up to speed on the AS3, but keep having problems that seem like they shouldnt be happening.

first, i have 6 movie clips on my stage… named b1-b6.  
those are my buttons.

this simple code (on main timeline) doesn’t work:

[AS]  
var main:MovieClip = this  
function initNav ()  
{  
for (var i:uint=1; i\<=6; i++)  
{  
main[“b” + i].addEventListener (MouseEvent.MOUSE\_DOWN, mainPress);  
main[“b”+i].datahold = i;  
main[“b”+i].buttonMode = true;  
}  
}  
initNav ();  
//-----------------------------------------------------------------------------------------------  
function mainPress (e:Event):void  
{  
trace(e.target.datahold)  
}  
[/AS]

the trace returns undefined? why cant the datahold variable be added to the movie clip?

if i try to trace:  
[AS]  
trace(e.target.name)  
[/AS]

i get results like instance17. which isnt the name or instance name of the movie clip at all.

the code looks simple enough, and it looks correct. what am i missing here?  
Thanks
