Macromedia flex 2-migrating applications to flex 2 Manual De Usuario
112
Events
About events
The following list is a general overview of the changes to the Event model. Review all event
handling in your Flex application by using these guidelines.
handling in your Flex application by using these guidelines.
■
All event objects are either of type Event or a subclass of Event. You should explicitly
declare or cast them to their appropriate type.
declare or cast them to their appropriate type.
■
Use static constants such as
MouseEvent.CLICK
instead of string literals for the event
type, such as “
click
”. For more information, see
.
■
Do not use object event listeners. Instead use function listeners. For more information, see
■
Scoping in event listeners is improved. You no longer need to pass a Delegate to maintain
scope.
scope.
■
Use the
currentTarget
property instead of the
target
property when you access the
object that is listening for the event. The
target
property refers to the object that
dispatched the event.
Subclasses of Event, such as MouseEvent, have all the properties of the Event object and
properties that are specific to that type of event. Choosing the most specific type possible
provides the following benefits:
properties that are specific to that type of event. Choosing the most specific type possible
provides the following benefits:
■
Faster run-time performance
■
Compile-time type-checking
■
Access to event-specific properties
■
Smaller SWF file size
Component startup life cycle
The ordering of events during a component’s initialization has changed. The
initialize
event is now named
preinitialize
.
The
initialize
event now occurs after children are added to the component. As a result,
instead of calling an event handler for the
creationComplete
event, you can use the
initialize
event handler to perform most initialization tasks. You typically call
creationComplete
when you have to wait until the LayoutManager has processed the
children so that the
x
,
y
,
width
, and
height
properties are known.
The
childrenCreated
event has been removed. You should use the
initialize
event
instead.
A new event,
applicationComplete
, has been added. This event is the last one dispatched
when an application starts up.