Class org.as2lib.env.event.impulse.AbstractImpulse

org.as2lib.core.BasicClass
   +--org.as2lib.env.event.impulse.AbstractImpulse

Description

AbstractImpulse is a helper class that contains shared API to be used by different Impulse Implementations.

Method Index

new AbstractImpulse()

addAllImpulseListeners(), addAllListeners(), addImpulseListener(), addListener(), connectAllExecutables(), connectExecutable(), disconnectAllExecutables(), disconnectExecutable(), getAllConnectedExecutables(), getAllImpulseListeners(), getAllListeners(), hasImpulseListener(), hasListener(), isExecutableConnected(), removeAllImpulseListeners(), removeAllListeners(), removeImpulseListener(), removeListener()

Inherited from BasicClass

toString()

Constructor Detail

AbstractImpulse

public function AbstractImpulse()

Constructs a new impulse.

Method Detail

connectExecutable

public function connectExecutable(exe:Executable):Void

Connects a executable as listener to the frame execution.

Parameters

exeExecutable to be added as listener

addAllListeners

public function addAllListeners(listeners:Array):Void

Adds a list of listeners to listen to the impulse events.

Parameters

listenersList of listeners to be added.

Throws

IllegalArgumentExceptionif a listener could not be added.

addListener

public function addListener(listener):Void

Method to add any supported listener to the FrameImpulse.

Adds a listener to the Impulse. The listener will be informed on each frame change.

Note: If a certain listener implements more than one supported event it will listen to all of them at one execution (execute, onFrameImpulse, onImpulse).

Parameters

listenerto be added.

Throws

IllegalArgumentExceptionif the listener doesn't match any type.

addImpulseListener

public function addImpulseListener(listener:ImpulseListener):Void

Methode to add a ImpulseListener as listener to the Impulse.

Some parts of the code get better readable if you use a complete clear name like "onImpulse" to define your code. With .addImpulseListener you can add a listener that specially listens only to this naming of the same event that will be executed as "execute".

Example:

Listener: import org.as2lib.env.event.impulse.ImpulseListener; import org.as2lib.env.event.impulse.Impulse; class TraceTimeImpulseListener implements ImpulseListener { public function onImpulse(impulse:Impulse):Void { trace("Impulse executed at "+getTimer()); } }

Usage: import org.as2lib.env.event.impulse.FrameImpulse; var impulse:FrameImpulse = FrameImpulse.getInstance(); impulse.addImpulseListener(new TraceTimeImpulseListener());

Parameters

listenerListener to be added.

removeListener

public function removeListener(listener):Void

Removes a listener of any type that might be added.

Parameters

listenerListener to be removed.

Throws

IllegalArgumentExceptionif you pass a listener that is of a illegal type.

disconnectExecutable

public function disconnectExecutable(exe:Executable):Void

Disconnects a Executable from listening to the impulse.

Parameters

exeExecutable to disconnect.

removeImpulseListener

public function removeImpulseListener(listener:ImpulseListener):Void

Removes a ImpulseListener from listening to the impulse.

Parameters

listenerImpulseListener to remove from listening.

removeAllListeners

public function removeAllListeners(Void):Void

Removes all added Listeners from listening to the impulse.

removeAllImpulseListeners

public function removeAllImpulseListeners(Void):Void

Removes all added ImpulseListeners from listening to the impulse.

disconnectAllExecutables

public function disconnectAllExecutables(Void):Void

Disconnects all connected Executables from the impulse.

getAllListeners

public function getAllListeners(Void):Array

Getter for the list of all added listeners.

This method returns a list of all listeners added with eihter connectExecutable, addListener or addImpulseListener

Return

List that contains all added listeners.

getAllConnectedExecutables

public function getAllConnectedExecutables(Void):Array

Getter for the list of all connected Executables.

Return

List that contains all connected Executables.

getAllImpulseListeners

public function getAllImpulseListeners(Void):Array

Getter for the list of all added ImpulseListeners.

Return

List that contains all added ImpulseListeners.

addAllImpulseListeners

public function addAllImpulseListeners(listeners:Array):Void

Adds a list of ImpulseListeners as listener to the events.

Parameters

listenersList of all listeners to add.

Throws

IllegalArgumentExceptionif one listener didn't match to any listener type.

connectAllExecutables

public function connectAllExecutables(executables:Array):Void

Connects a list of Executabless to the impulse.

Parameters

Throws

IllegalArgumentExceptionif one listener didn't match to any listener type.

hasListener

public function hasListener(listener):Boolean

Validates if a certain listener of any type is currently added to the impulse.

Parameters

listenerListener to be validated.

Return

true if the certain executable is connected.

hasImpulseListener

public function hasImpulseListener(listener:ImpulseListener):Boolean

Validates if a certain ImpulseListener is currently added to the impulse.

Parameters

listenerImpulseListener to be validated.

Return

true if the certain executable is connected.

isExecutableConnected

public function isExecutableConnected(exe:Executable):Boolean

Validates if a certain Executable is currently connected to the impulse.

Parameters

exeExecutable to be validated.

Return

true if the certain executable is connected.