Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 142

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Your custom component can also define event listeners within the component itself to handle
the events internally. For example,
defined event listeners for the
component. This allows the component to handle those events internally.
Even though you define event listeners for the events in the component itself, your
application can also register listeners for those events. The event listeners defined within
the component execute before any listeners defined in the application.
The example used the
the component. You could not access this property in the constructor itself because Flex does
not define it until after the component is created. For more information on the initialization
order of a component, see
ActionScript," on page
Dispatching custom events
Your ActionScript component can define custom events and use the predefined events. You
use custom events to support data binding, to respond to user interactions, or to trigger
actions by your component. For an example that uses events to support data binding, see
"Using data binding with custom properties" on page
For each custom event dispatched by your component, you must do the following:
Create an
Event
object describing the event.
1.
(Optional) use the
2.
components can listen for it.
Dispatch the event by using the
3.
To add information to the event object, you define a subclass of the flash.events.Event class to
represent the event object. For more information on creating custom event classes, see
Chapter 4, "Creating Custom Events," on page
142
Creating Simple Visual Components in ActionScript
"Defining public properties as variables" on page 127
and
keyDown
event to access the default
creationComplete
Chapter 10, "Creating Advanced Visual Components in
147.
metadata tag to make the event public so that other
[Event]
dispatchEvent()
events within the body of the
creationComplete
132.
method.
35.
property of
fontSize

Advertisement

Table of Contents
loading

Table of Contents