Packagecom.bourre.events
Classpublic class ChannelBroadcaster
SubclassesApplicationBroadcaster

Player version: Flash Player 9.0
Language version: ActionScript 3.0

The ChannelBroadcaster is a macro broadcaster which offer to dispatch events over communication channels.

The main idea is the following, developpers can create specific channels for communication, onto which event will be broadcasted. To take a metaphor, is like a CB radio, you can select a frequency and then you will listen and talk to people which are connected to that frequency, and only that one. To achieve this process, the channel broadcaster aggregates Broadcaster implementation and map it with EventChannel object. In that principle the channel broadcaster is no more than a CB base station. With a big difference anyway, the broadcaster channel offers an access to a frequency, it doesn't broadcast messages itself.

To initiate the dispatching on a specific channel, developers only need to call the redefined functions of the class as they can do with a Broadcaster implementation with a proper event channel, the channel broadcaster will check for the presence of a broadcaster instance for this channel, and if there's no corresponding broadcaster it will create it.

The channel broadcaster redefines many functions of the Broadcaster interface in order to add the channel parameter. See below the list of redefined methods :

See also

Broadcaster.html
EventChannel.html


Protected Properties
 PropertyDefined by
  _broadcasterClass : Class
ChannelBroadcaster
  _mChannel : HashMap
ChannelBroadcaster
  _oDefaultChannel : EventChannel
ChannelBroadcaster
Public Methods
 MethodDefined by
  
ChannelBroadcaster(broadcasterClass:Class = null, channel:EventChannel = null)
Creates a new ChannelBroadcaster with the passed-in Broadcaster class to build broadcaster instances and an event channel as default channel.
ChannelBroadcaster
  
addEventListener(type:String, listener:Object, channel:EventChannel = null):Boolean
Adds an event listener for the specified event type of the specified channel.
ChannelBroadcaster
  
addListener(listener:Object, channel:EventChannel = null):Boolean
Adds the passed-in listener as listener for all events dispatched by this event channel broadcaster.
ChannelBroadcaster
  
broadcastEvent(e:Event, channel:EventChannel = null):void
Broadcast the passed-in event object to listeners according to the event's type and channel argument.
ChannelBroadcaster
  
empty():void
Clean the current channel broacaster by removing all Broadcaster instances previously created and then rebuild the default EventBroadcaster.
ChannelBroadcaster
  
getChannelDispatcher(channel:EventChannel = null, owner:Object = null):Broadcaster
Returns the Broadcaster instance associated with the passed-in channel.
ChannelBroadcaster
  
Returns a reference to the default channel of this channel broadcaster.
ChannelBroadcaster
  
Returns the Broadcaster implementation associated with the default channel of this channel broadcaster.
ChannelBroadcaster
  
Returns true if there is a Broadcaster instance registered for the passed-in channel.
ChannelBroadcaster
  
hasChannelListener(type:String, channel:EventChannel = null):Boolean
Returns true if there is a Broadcaster instance registered for the passed-in channel, and if this broadcaster has registered listeners.
ChannelBroadcaster
  
isRegistered(listener:Object, type:String, channel:EventChannel):Boolean
Returns true if the passed-in listener is registered as listener for the passed-in event type in the passed-in channel.
ChannelBroadcaster
  
Removes the Broadcaster instance associated with the passed-in channel, and return true if there is a broadcaster and if it have been successfully removed.
ChannelBroadcaster
  
removeEventListener(type:String, listener:Object, channel:EventChannel = null):Boolean
Removes the passed-in listener for listening the specified event of the specified channel.
ChannelBroadcaster
  
removeListener(listener:Object, channel:EventChannel = null):Boolean
Removes the passed-in listener object from this event channel broadcaster.
ChannelBroadcaster
  
setDefaultChannel(channel:EventChannel = null):void
Defines which channel is used as default channel for this channel broadcaster.
ChannelBroadcaster
  
toString():String
Returns the string representation of this instance.
ChannelBroadcaster
Property detail
_broadcasterClassproperty
protected var _broadcasterClass:Class

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_mChannelproperty 
protected var _mChannel:HashMap

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_oDefaultChannelproperty 
protected var _oDefaultChannel:EventChannel

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Constructor detail
ChannelBroadcaster()constructor
public function ChannelBroadcaster(broadcasterClass:Class = null, channel:EventChannel = null)

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates a new ChannelBroadcaster with the passed-in Broadcaster class to build broadcaster instances and an event channel as default channel. The default channel is used when a call to function is done without specifying any channel. If the channel argument is omitted, the default channel is set to the internal DefaultChannel.CHANNEL constant.

Parameters
broadcasterClass:Class (default = null) — broadcaster class wrapped by this channel broadcaster
 
channel:EventChannel (default = null) — default channel for this broadcaster

Throws
IllegalArgumentException — If the passed-in class doesn't implement Broadcaster interface
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Object, channel:EventChannel = null):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds an event listener for the specified event type of the specified channel. There is two behaviors for the addEventListener function :

  1. The passed-in listener is an object : The object is added as listener only for the specified event, the object must have a function with the same name than type or at least a handleEvent function.
  2. The passed-in listener is a function : A Delegate object is created and then added as listener for the event type . There is no restriction on the name of the function.

Parameters
type:String — type name of the event for which register the listener
 
listener:Object — listener object or function which will receive this event
 
channel:EventChannel (default = null) — event channel for which the listener listen

Returns
Booleantrue if the function have been succesfully added as listener fot the passed-in event

Throws
UnsupportedOperationException — If the listener is an object which have neither a function with the same name than the event type nor a function called handleEvent

See also

addListener()method 
public function addListener(listener:Object, channel:EventChannel = null):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds the passed-in listener as listener for all events dispatched by this event channel broadcaster. The function returns true if the listener have been added at the end of the call. If the listener is already registered in this event channel broadcaster the function returns false.

Note : The addListener function doesn't accept functions as listener, functions could only register for a single event.

Parameters
listener:Object — listener the listener object to add as channel listener
 
channel:EventChannel (default = null) — the channel for which the object listen

Returns
Booleantrue if the listener have been added during this call

Throws
IllegalArgumentException — If the passed-in listener listener doesn't match the listener type supported by this broadcaster instance
 
IllegalArgumentException — If the passed-in listener is a function

See also

broadcastEvent()method 
public function broadcastEvent(e:Event, channel:EventChannel = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Broadcast the passed-in event object to listeners according to the event's type and channel argument. The event is broadcasted to both listeners registered specifically for this event type and global listeners in the broadcaster.

If the target property of the passed-in event is null, it will be set using the value of the source property of this event broadcaster.

Parameters
e:Event — event object to broadcast
 
channel:EventChannel (default = null) — channel event channel onto which broadcast event

Throws
UnsupportedOperationException — If one listener is an object which have neither a function with the same name than the event type nor a function called handleEvent

See also

empty()method 
public function empty():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Clean the current channel broacaster by removing all Broadcaster instances previously created and then rebuild the default EventBroadcaster.

getChannelDispatcher()method 
public function getChannelDispatcher(channel:EventChannel = null, owner:Object = null):Broadcaster

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the Broadcaster instance associated with the passed-in channel. The owner is an optionnal parameter which is used to initialize the newly created Broadcaster when there is no broadcaster for this channel.

Parameters
channel:EventChannel (default = null) — the channel for which get the associated broadcaster
 
owner:Object (default = null) — an optional object which will used as source if there is no broadcaster associated to the channel

Returns
Broadcaster — the Broadcaster instance associated with the passed-in channel
getDefaultChannel()method 
public function getDefaultChannel():EventChannel

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns a reference to the default channel of this channel broadcaster. This function never returns null.

Returns
EventChannel — a reference to the default channel of this channel broadcaster
getDefaultDispatcher()method 
public function getDefaultDispatcher():Broadcaster

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the Broadcaster implementation associated with the default channel of this channel broadcaster.

Returns
Broadcaster — the Broadcaster implementatation associated with the default channel of this channel broadcaster
hasChannelDispatcher()method 
public function hasChannelDispatcher(channel:EventChannel):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if there is a Broadcaster instance registered for the passed-in channel.

Parameters
channel:EventChannel — channel onto which look at

Returns
Booleantrue if there is a Broadcaster instance registered for the passed-in channel
hasChannelListener()method 
public function hasChannelListener(type:String, channel:EventChannel = null):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if there is a Broadcaster instance registered for the passed-in channel, and if this broadcaster has registered listeners.

Parameters
type:String — event type to look at
 
channel:EventChannel (default = null) — channel onto which look at

Returns
Booleantrue if there is a Broadcaster instance registered for the passed-in channel, and if this broadcaster has registered listeners
isRegistered()method 
public function isRegistered(listener:Object, type:String, channel:EventChannel):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if the passed-in listener is registered as listener for the passed-in event type in the passed-in channel.

Parameters
listener:Object — object to look for registration
 
type:String — event type to look at
 
channel:EventChannel — channel onto which look at

Returns
Booleantrue if the passed-in listener is registered as listener for the passed-in event type in the passed-in channel

See also

releaseChannelDispatcher()method 
public function releaseChannelDispatcher(channel:EventChannel):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the Broadcaster instance associated with the passed-in channel, and return true if there is a broadcaster and if it have been successfully removed.

Parameters
channel:EventChannel — channel for which remove the associated broadcaster

Returns
Booleantrue if there is a broadcaster and if it have been successfully removed.
removeEventListener()method 
public function removeEventListener(type:String, listener:Object, channel:EventChannel = null):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the passed-in listener for listening the specified event of the specified channel. The listener could be either an object or a function.

Parameters
type:String — type name of the event for which unregister the listener
 
listener:Object — listener object or function to be unregistered
 
channel:EventChannel (default = null) — event channel on which unregister the listener

Returns
Booleantrue if the listener have been successfully removed as listener for the passed-in event

See also

removeListener()method 
public function removeListener(listener:Object, channel:EventChannel = null):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the passed-in listener object from this event channel broadcaster. The object is removed as listener for all events the broadcaster may dispatch on this channel.

Parameters
listener:Object — the listener object to remove from this event broadcaster object
 
channel:EventChannel (default = null) — the channel for which the object will be removed

Returns
Booleantrue if the object have been successfully removed from this broadcaster instance

Throws
IllegalArgumentException — If the passed-in listener is a function

See also

setDefaultChannel()method 
public function setDefaultChannel(channel:EventChannel = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Defines which channel is used as default channel for this channel broadcaster. If the passed-in channel is null the internal DefaultChannel.CHANNEL constant is used as default channel.

Parameters
channel:EventChannel (default = null) — the new default channel for this channel broadcaster
toString()method 
public function toString():String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the string representation of this instance.

Returns
String — the string representation of this instance