The
event object inherits from the Event object class and has properties
that contain information about the event that occurred, including
the
target
and
type
properties,
which provide essential information about the event:
Property
|
Description
|
type
|
A string indicating the type of the event.
|
target
|
A reference to the component instance broadcasting
the event.
|
When an event has additional properties, they are listed in the
event’s class description in the
ActionScript 3.0 Reference for the Adobe
Flash Platform
.
The event object is automatically generated and passed to the
event handler function when an event occurs.
You can use the event object inside the function to access the
name of the event that was broadcast or the instance name of the
component that broadcast the event. From the instance name, you
can access other component properties. For example, the following
code uses the
target
property of the
evtObj
event object
to access the
label
property of
aButton
and
display it in the Output panel:
import fl.controls.Button;
import flash.events.MouseEvent;
var aButton:Button = new Button();
aButton.label = "Submit";
addChild(aButton);
aButton.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(evtObj:MouseEvent){
trace("The " + evtObj.target.label + " button was clicked");
}