Class org.as2lib.env.event.EventSupport

Implemented Interfaces

EventListenerSource

Description

EventSupport provides simple access to events.

To apply event abilities to your class its only necessary to extend EventSupport. It holds in the private instance variable distributorControl a reference to SimpleConsumableCompositeEventDistributionControl.

To allow additional listener types to be checked by addListener, addAddListener its only necessary to add acceptListenerType(AnyType); within the constructor of the extended class.

It is necessary for sending a event to recieve the matching distributor with distributorControl.getDistributor(AnyType) and execute the event to it.

Example code: class Controller extends EventSupport { private var model:Model; private var distributor:View; public function Controller(Void) { distributorControl.acceptListenerType(View); distributor = distributorControl.getDistributor(View); } public function setTargetModel(model:Model) { this.model = model; distributor.onTargetModelChanged(this); } public function getTargetModel(Void):Model { return model; } }

Field Index

Inherited from LogSupport

Method Index

new EventSupport()
addAllListeners(), addListener(), getAllListeners(), hasListener(), removeAllListeners(), removeListener()

Inherited from LogSupport

Inherited from BasicClass

Constructor Detail

EventSupport

function EventSupport(Void)

Constructs a new EventSupport instance.

Method Detail

addListener

public function addListener(listener):Void

Adds the passed-in listener to be executed by events.

Parameters

listenerthe listener to add

Throws

IllegalArgumentExceptionif the listener does not match any expected type

Specified By

addListener() in org.as2lib.env.event.EventListenerSource

addAllListeners

public function addAllListeners(listeners:Array):Void

Adds all listener contained in the passed-in listeners array.

All listeners get added after each other. If one listener does not match any expected type the rest of the listeners will not be added an a exception will raise.

Parameters

listenersthe list of listeners to add

Throws

IllegalArgumentExceptionif any listener does not match any expected type

Specified By

addAllListeners() in org.as2lib.env.event.EventListenerSource

removeListener

public function removeListener(listener):Void

Removes the passed-in listener from beeing executed by events.

Parameters

listenerthe listener to remove

Specified By

removeListener() in org.as2lib.env.event.EventListenerSource

removeAllListeners

public function removeAllListeners(Void):Void

Removes all listeners from beeing executed by events.

Specified By

removeAllListeners() in org.as2lib.env.event.EventListenerSource

getAllListeners

public function getAllListeners(Void):Array

Getter for the list of all added listeners.

This method returns a copy (not a reference) of the list of all added listeners.

Return

list that contains all added listeners

Specified By

getAllListeners() in org.as2lib.env.event.EventListenerSource

hasListener

public function hasListener(listener):Boolean

Checks if the passed-in listener has been added.

Return

true if the listener has been added

Specified By

hasListener() in org.as2lib.env.event.EventListenerSource