MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual do Utilizador Página 109

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 184
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 108
Binding from a property 109
Dispatching binding events from a custom
component
To dispatch an event to trigger data binding for a property, the propertys class must either
extend EventDispatcher or implement the IEventDispatcher interface. Be sure to update the
object that is passed to the
dispatchEvent() method. You must use the new Event class and
not a generic Object. For more information on converting events, see “Migrating the Event
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
dispatchEvent(), too. If the class
does not implement
dispatchEvent(), the MXML compiler reports a warning.
If the class does not extend EventDispatcher or implement IEventDispatcher and one of your
properties is marked
[Bindable] or the class is marked [Bindable], the MXML compiler
modifies the class to implement IEventDispatcher. This requires the compiler to generate the
following code for you:
Implements the IEventDispatcher interface.
Adds an addEventListener() method.
Adds a removeEventListener() method.
Adds a dispatchEvent() method.
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.
Vista de página 108
1 2 ... 104 105 106 107 108 109 110 111 112 113 114 ... 183 184

Comentários a estes Manuais

Sem comentários