Packagesystem.broadcasters
Classpublic class FastDispatcher
InheritanceFastDispatcher Inheritance InternalBroadcaster Inheritance Object

This class provides a fast event dispatcher based "Observer" event model (like ASBroadcaster in AS1) but used Event object to dispatch the message to the listeners.

Example :

     package examples 
     {
         import system.events.BasicEvent;
         import system.events.FastDispatcher;
         
         import flash.display.Sprite;
         import flash.events.Event;
         
         [SWF(width="740", height="480", frameRate="24", backgroundColor="#666666")]
         
         public class FastDispatcherExample extends Sprite
         {
             public function FastDispatcherExample()
             {
                 var dispatcher:FastDispatcher = new FastDispatcher() ;
                 
                 dispatcher.addListener( this ) ;
                 
                 dispatcher.broadcastMessage( "onCallback" ) ;
                 dispatcher.dispatch( new BasicEvent( "onCallback" ) ) ;
             }
             
             public function onCallback( e:Event ):void
             {
                 trace( e ) ;
             }
         }
     }
     



Public Properties
 PropertyDefined By
 Inheritedlength : uint
[read-only] Indicates the number of listeners registered in the Broadcaster.
InternalBroadcaster
Protected Properties
 PropertyDefined By
 Inheritedlisteners : Vector.<BroadcasterEntry>
The Vector representation of all listeners.
InternalBroadcaster
Public Methods
 MethodDefined By
  
FastDispatcher(listeners:Array = null)
Creates a new FastDispatcher instance.
FastDispatcher
 Inherited
addListener(listener:*, priority:uint = 0, autoRemove:Boolean = false):Boolean
Registers an object to receive messages.
InternalBroadcaster
  
broadcastMessage(message:String, ... rest):*
[override] Broadcast the specified message.
FastDispatcher
  
dispatch(event:Event):void
Sends an Event Object to each object in the list of listeners.
FastDispatcher
 Inherited
hasListener(listener:*):Boolean
Returns true if this dispatcher contains the specified listener.
InternalBroadcaster
 Inherited
isEmpty():Boolean
Returns true if the set of listeners is empty.
InternalBroadcaster
 Inherited
removeListener(listener:* = null):Boolean
Removes the specified listener or all listeners if the parameter is null.
InternalBroadcaster
 Inherited
toArray():Array
Returns the Array representation of all listeners.
InternalBroadcaster
Constructor Detail
FastDispatcher()Constructor
public function FastDispatcher(listeners:Array = null)

Creates a new FastDispatcher instance.

Parameters
listeners:Array (default = null) — The Array collection of listeners to register in the dispatcher.
Method Detail
broadcastMessage()method
override public function broadcastMessage(message:String, ... rest):*

Broadcast the specified message.

Parameters

message:String — The message to broadcast.
 
... rest — Optional parameters passed in with the broadcast message.

Returns
*
dispatch()method 
public function dispatch(event:Event):void

Sends an Event Object to each object in the list of listeners. When the Event is received by the listening object, Flash Player attempts to invoke a function of the same name on the Event.type property.

Parameters

event:Event