# \[How to\] get object name in addEventListener?

**URL:** <https://forum.kirupa.com/t/how-to-get-object-name-in-addeventlistener/228581>\
**Category:** Uncategorized\
**Created:** [June 9, 2007, 5:41am UTC](https://forum.kirupa.com/t/how-to-get-object-name-in-addeventlistener/228581 "2007-06-09T05:41:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfree](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@manfree](https://forum.kirupa.com/u/manfree)\
**Post date:** [June 9, 2007, 5:41am UTC](https://forum.kirupa.com/t/how-to-get-object-name-in-addeventlistener/228581/1 "2007-06-09T05:41:07Z")

</div>

Hi all, I would like to ask …  
1.) How can I let the onClickHandler knows, which button has been clicked…  
2.) Is it possible to make it to a CLASS or what ??  
thanks ~~ 🙂

```auto
button1.addEventListener(MouseEvent.CLICK, onClickHandler);
button2.addEventListener(MouseEvent.CLICK, onClickHandler);
function onClickHandler(e:MouseEvent):void {
 / ************************************
  var [url:String](http://www.kirupa.com/forum/String);
  if (button1.CLICK) {
   url = "page1.htm";
  } else if (button2.CLICK) {
   url = "page2.htm";
  }
 
 ************************************* / 
 var vReq:URLRequest = new URLRequest(url);
 navigateToURL(vReq);
}

```
