Class fever.events.PriorityEventBroadcaster

Description

Dispatches events to all added listeners with the help of an BasicEvent and using listener priority to call handler in correct order.

The higher the number, the higher the priority.
All listeners with priority n are processed before listeners of priority n-1.
The default priority is 0.

Can use single access point using getInstance and get always the same #@link PriorityEventBroadcaster} instance.

See Also

Method Index

addEventListener(), addListener(), addPriorityListener(), broadcastEvent(), getInstance(), getListenerArray()

Method Detail

getInstance

static public function getInstance():PriorityEventBroadcaster

Returns PriorityEventBroadcaster instance.

Always return the same instance.

getListenerArray

public function getListenerArray(t:String):PriorityListenerArray

Returns an ListenerArray of listeners that suscribed for passed-in t event or for all events if parameter is omitted.

Parameters

tEvent type. If event type is undefined, method will return listeners that suscribed for all events.

Return

a PriorityListenerArray instance

addListener

public function addListener(listener, f:Function, priority:Number):Void

Adds passed-in listener for receiving all events.

Parameters

listenerListener object
f(optional) new callback function
priority( optionnal ) listener priority

addPriorityListener

public function addPriorityListener(listener, priority:Number):Void

Adds passed-in listener for receiving all events.

Parameters

listenerListener object
priority( optionnal ) listener priority

addEventListener

public function addEventListener(type:String, listener):Void

Adds passed-in listener for receiving passed-in event type event.

As we can pass many arguments in method call, priority value is retreive using the argument.length - 1 argument index.

   // priority == 10
   ob.addEventListener( "MyEvent", this, _handleCallback, "param1", "param2", 10 );
 

Parameters

broadcastEvent

public function broadcastEvent(e:IEvent):Void

Broadcasts event to suscribed listeners.

A listener sorting is applied before broadcasting.

Parameters

ean IEvent instance