# Event.target.name

**URL:** <https://forum.kirupa.com/t/event-target-name/256268>\
**Category:** Uncategorized\
**Created:** [April 1, 2008, 2:37pm UTC](https://forum.kirupa.com/t/event-target-name/256268 "2008-04-01T14:37:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alemieux34](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@alemieux34](https://forum.kirupa.com/u/alemieux34)\
**Post date:** [April 1, 2008, 2:37pm UTC](https://forum.kirupa.com/t/event-target-name/256268/1 "2008-04-01T14:37:09Z")

</div>

I’m trying to understand event.target.name. When it is used, the instance name of the button being targeted by the event listener and the label (or target) need to match in order for it to work, as in the following example:

```auto

function buttonClick(event:MouseEvent):void {
   **gotoAndStop(event.target.name);**
}
but1.addEventListener(MouseEvent.CLICK, buttonClick);
but2.addEventListener(MouseEvent.CLICK, buttonClick);
but3.addEventListener(MouseEvent.CLICK, buttonClick);

```

In the timeline there are three frames with the labels but1, but2, and but3, which correspond to the instance names of the buttons.

It all works, but why does it work?
