Class org.as2lib.env.event.multicaster.SimpleEventMulticaster

org.as2lib.core.BasicClass
   +--org.as2lib.env.event.SimpleEventListenerSource
      +--org.as2lib.env.event.multicaster.SimpleEventMulticaster

Implemented Interfaces

EventMulticaster

Description

SimpleEventMulticaster multicasts an event to all added listeners with custom arguments. This class does not support consuming events.

Example: // creates a multicaster for the 'onError' event var multicaster:SimpleEventMulticaster = new SimpleEventMulticaster("onError"); // adds listeners multicaster.addListener(new SimpleErrorListener()); multicaster.addListener(new MyErrorListener()); // executes the specified event on all listeners passing the given arguments multicaster.dispatch(myErrorCode, myException);

Method Index

new SimpleEventMulticaster()

dispatch(), getEventName(), removeAllListeners()

Inherited from SimpleEventListenerSource

addAllListeners(), addListener(), getAllListeners(), hasListener(), removeListener()

Inherited from BasicClass

toString()

Constructor Detail

SimpleEventMulticaster

public function SimpleEventMulticaster(eventName:String, listeners:Array)

Constructs a new SimpleEventMulticaster instance.

Parameters

eventNamethe name of the event to execute on all added listeners
listeners(optional) an array of listeners to populate this broadcaster with

Throws

IllegalArgumentExceptionif passed-in eventName is null, undefined or an empty string

Method Detail

getEventName

public function getEventName(Void):String

Returns the event name set on construction.

Return

the name of the event

removeAllListeners

public function removeAllListeners(Void):Void

dispatch

public function dispatch():Void

Dispatches the event to all added listeners passing the given arguments as parameters to the listeners' event methods.

Parameters

...any number of arguments to pass to the listeners' event methods

Throws

EventExecutionExceptionif a listener's event method threw an exception

Specified By

dispatch() in org.as2lib.env.event.multicaster.EventMulticaster