Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual page 109

Migrating applications to flex 2
Table of Contents

Advertisement

Dispatching binding events from a custom
component
To dispatch an event to trigger data binding for a property, the property's class must either
extend EventDispatcher or implement the IEventDispatcher interface. Be sure to update the
object that is passed to the
not a generic Object. For more information on converting events, see
object" on page
113.
If the class already extends EventDispatcher, you do not need to make any changes. If the class
already implements IEventDispatcher, it must implement
does not implement
dispatchEvent()
If the class does not extend EventDispatcher or implement IEventDispatcher and one of your
properties is marked
modifies the class to implement IEventDispatcher. This requires the compiler to generate the
following code for you:
Implements the IEventDispatcher interface.
Adds an
addEventListener()
Adds a
removeEventListener()
Adds a
dispatchEvent()
For example, the following declaration:
class Foo {
}
Is converted by the Flex compiler to the following:
class Foo implements IEventDispatcher {
private var bar:EventDispatcher = new EventDispatcher(this);
public function addEventListener(type:String, listener:Object,
useCapture:Boolean = false, priority:int = 0):Boolean {
return bar.addEventListener(type, listener, useCapture, priority);
}
public function removeEventListener(type:String, listener:Object,
useCapture:Boolean = false):Boolean {
return bar.removeEventListener(type, listener, useCapture);
}
public function dispatchEvent(event:Event):void {
bar.dispatchEvent(event);
}
}
For more information, see Creating and Extending Flex 2 Components.
dispatchEvent()
, the MXML compiler reports a warning.
or the class is marked
[Bindable]
method.
method.
method.
method. You must use the new Event class and
dispatchEvent()
[Bindable]
Binding from a property
"Migrating the Event
, too. If the class
, the MXML compiler
109

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents