MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual page 68

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

The event object has an implicit property,
the event.
For more information on events, see Developing Flex Applications.
Defining event handlers
You define the event handler object or event handler function that listens for your component's
events in your application's ActionScript. The following example handles the
and
events of the children of the component:
click
function handleEvent(evt:Object):Void {
if (evt.type == "change") {
dispatchEvent({ type: "change" });
} else if (evt.type == "focusOut") {
text_mc.editable = false;
} else if (evt.type = "click") {
text_mc.editable = !text_mc.editable;
}
}
Using the Event metadata
Add Event metadata in your ActionScript class file for each event listener. The value of the
keyword becomes the first argument in calls to the
following example shows:
[Event("click")] // Event declaration.
...
class FCheckBox{
function addEventListener(eventName:String, eventHandler:Object) {
... // eventName is String
}
}
Event metadata describes the events that this component emits, not the ones it consumes. For
more information on the
About invalidation
Macromedia recommends that a component not update itself immediately in most cases, but
instead save a copy of the new property value, set a flag indicating what is changed, and call one of
the three invalidation methods.
The following are the invalidation methods:
invalidateSize()
in a call to the
measure()
properties, it calls the
_measured
invalidateLayout()
changed, but the
layoutChildren()
should call the
invalidate()
68
Chapter 3: Creating Advanced Components in Flash MX 2004
metadata keyword, see
Event
Indicates that one of the
method. If the
layoutChildren()
Indicates that the position and/or size of one of the subobjects may have
properties have not been affected. This results in a call to the
_measured
method. If you change a subobject in the
method.
, that is a reference to the object that triggered
target
addEventListener()
"Event" on page
properties may have changed. This results
_measured
method changes the value of one of the
measure()
method.
layoutChildren()
,
change
focusOut
Event
method, as the
62.
method, you
,

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents