# How to detect what was clicked in the function after addEventListener?

**URL:** <https://forum.kirupa.com/t/how-to-detect-what-was-clicked-in-the-function-after-addeventlistener/263994>\
**Category:** Uncategorized\
**Created:** [June 21, 2008, 5:41pm UTC](https://forum.kirupa.com/t/how-to-detect-what-was-clicked-in-the-function-after-addeventlistener/263994 "2008-06-21T17:41:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fullofebak](https://avatars.discourse-cdn.com/v4/letter/f/87869e/32.png) [@fullofebak](https://forum.kirupa.com/u/fullofebak)\
**Post date:** [June 21, 2008, 5:41pm UTC](https://forum.kirupa.com/t/how-to-detect-what-was-clicked-in-the-function-after-addeventlistener/263994/1 "2008-06-21T17:41:10Z")

</div>

image\_mc.addEventListener(MouseEvent.CLICK, thumbclick);  
function thumbclick(evt:MouseEvent):void  
{  
currentPath = MouseEvent.target;  
trace(event.target);  
}

…I know u can use event.target.data in the UILoader, but what about here on mouseevents? Been trying diff. stuff… no luck. : (

---

<div class="post-metadata">

**Author:** ![DiamondDog](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@DiamondDog](https://forum.kirupa.com/u/DiamondDog)\
**Post date:** [June 21, 2008, 9:06pm UTC](https://forum.kirupa.com/t/how-to-detect-what-was-clicked-in-the-function-after-addeventlistener/263994/2 "2008-06-21T21:06:27Z")

</div>

```auto
 function thumbclick(evt:MouseEvent):void
{
// evt.target refers to whatever was clicked to cause thumbclick to be called

// so, if image_mc is the only thing that has an event listener calling thumbclick
// then evt.target will refer to image_mc

}

```

---

<div class="post-metadata">

**Author:** ![swd120](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@swd120](https://forum.kirupa.com/u/swd120)\
**Post date:** [June 23, 2008, 7:03pm UTC](https://forum.kirupa.com/t/how-to-detect-what-was-clicked-in-the-function-after-addeventlistener/263994/3 "2008-06-23T19:03:20Z")

</div>

image\_mc1.addEventListener(MouseEvent.CLICK, thumbclick);  
image\_mc2.addEventListener(MouseEvent.CLICK, thumbclick);

function thumbclick(evt:MouseEvent):void  
{  
switch(evt.target.name){  
case “image\_mc1”:  
trace(“Image 1 clicked”);  
break;  
case “image\_mc2”:  
trace(“image 2 clicked”);  
break;  
}

}
