About The Event Object - MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

// 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.
Property
type
target
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.
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
property of the
target
instance and sends the value to the Output panel:
var myButton:mx.controls.Button;
var listener:Object;
listener = new Object();
listener.click = function(evtObj){
trace("The " + evtObj.target.label + " button was clicked");
}
myButton.addEventListener("click", listener);
66
Chapter 4: Handling Component Events
Description
A string indicating the name of the event.
A reference to the component instance broadcasting the event.
event object to access the
evtObj
property of the
label
myButton

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents