User Guide
About the event object 77
To access the properties and methods of the Cart class, call Delegate.create() as the second
parameter of
addEventListener(), as follows:
import mx.utils.Delegate;
import mx.controls.Button;
import mx.controls.CheckBox;
class Cart {
var myCheckBox_chb:CheckBox;
var myButton_btn:Button;
// define a variable to access
// from the chb_onClick function
var i:Number = 10
function onLoad() {
myCheckBox_chb.addEventListener("click", Delegate.create(this,
chb_onClick));
}
function chb_onClick(eventObj:Object) {
// Sends 10 to the Output panel
// because the function is scoped to
// the Cart instance
trace(i);
}
}
About the event object
The event object is an instance of the ActionScript Object class; it has the following properties
that contain information about an event.
When an event has additional properties, they are listed in the event’s entry in the
Components Dictionary.
The event object is automatically generated when an event is triggered and passed to the
listener object’s callback function or the listener function.
Property Description
type
A string indicating the name of the event.
target
A reference to the component instance broadcasting the event.