| 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 :
isRegistered
broadcastEvent
addListener
addEventListener
removeListener
removeEventListener
hasChannelListener, which correspond
to the hasListenerCollection method of the
EventBroadcaster class .
protected var _broadcasterClass:Class
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
protected var _mChannel:HashMap
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
protected var _oDefaultChannel:EventChannel
| Player version: | Flash Player 9.0 |
| Language version: | ActionScript 3.0 |
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
|
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 :
- 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.
- 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
| Boolean — true 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
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
| Boolean — true 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
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
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.
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
|
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
|
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
|
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
Returns
| Boolean — true if there is a Broadcaster
instance registered for the passed-in channel
|
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
| Boolean — true if there is a Broadcaster
instance registered for the passed-in channel, and if this
broadcaster has registered listeners
|
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
| Boolean — true if the passed-in listener
is registered as listener for the passed-in event
type in the passed-in channel
|
See also
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
| Boolean — true if there is a broadcaster and if it have
been successfully removed.
|
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
| Boolean — true if the listener have been successfully removed
as listener for the passed-in event
|
See also
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
| Boolean — true if the object have been successfully
removed from this broadcaster instance
|
Throws
| — IllegalArgumentException — If the passed-in listener
is a function
|
See also
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
|
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
|
LowRA API documentation 2008- 2009
Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1
mer. févr. 25 2009, 9:22 AM GMT+01:00