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:
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?