Interface org.as2lib.env.event.impulse.Impulse

org.as2lib.core.BasicInterface
   +--org.as2lib.env.event.EventListenerSource
      +--org.as2lib.env.event.impulse.Impulse

Description

Impulse is a definition for events that gets executed periodically.

Periodical events could be frame executions, seconds, hours or dates. Impulse allows to seperate the certain kind of Impulse from the execution code.

The Impulse executes Executable.execute on each impulse to the connected executables. Example: import org.as2lib.env.event.impulse.Impulse; import org.as2lib.env.event.impulse.FrameImpulse; import org.as2lib.app.exec.Call; function test(impulse:Impulse) { trace(impulse+" executed at "+getTimer()+"ms"); } var impulse:Impulse = FrameImpulse.getInstance(); impulse.connectExecutable(new Call(this, test));

Additionally its possible to work with the impulse as EventListenerSource. With you can add ImpulseListener implementations as listener to the code. Listener: import org.as2lib.env.event.impulse.ImpulseListener; import org.as2lib.env.event.impulse.Impulse; class TraceImpulseListener implements ImpulseListener { public function onImpulse(impulse:Impulse):Void { trace(impulse+" executed at "+getTimer()+"ms"); } } Test: import org.as2lib.env.event.impulse.Impulse; import org.as2lib.env.event.impulse.FrameImpulse; var impulse:Impulse = FrameImpulse.getInstance(); impulse.addImpulseListener(new TraceImpulseListener());

The addListener referes to eighter or to depending to what kind of listener you pass. If you pass a not-matching impulse it will throw a IllegalArgumentException.

Method Index

addAllImpulseListeners(), addImpulseListener(), connectAllExecutables(), connectExecutable(), disconnectAllExecutables(), disconnectExecutable(), getAllConnectedExecutables(), getAllImpulseListeners(), hasImpulseListener(), isExecutableConnected(), removeAllImpulseListeners(), removeImpulseListener()

Inherited from EventListenerSource

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

Inherited from BasicInterface

toString()

Method Detail

addImpulseListener

public function addImpulseListener(listener:ImpulseListener):Void

Adds a ImpulseListener for listening to the onImpulse event to the Impulse.

Parameters

listenerListener to be added.

removeImpulseListener

public function removeImpulseListener(listener:ImpulseListener):Void

Removes a added ImpulseListener from listening to the onImpulse event.

If the certain listener also implements other event types it will also be remove from listening to those events.

Parameters

listenerListener to be added.

addAllImpulseListeners

public function addAllImpulseListeners(listener:Array):Void

Adds a list of ImpulseListeners as listener to the events.

Parameters

Throws

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

getAllImpulseListeners

public function getAllImpulseListeners(Void):Array

Getter for the list of all added ImpulseListeners.

Return

List that contains all added listeners.

hasImpulseListener

public function hasImpulseListener(listener:ImpulseListener):Boolean

Checks if the listener has been added.

Parameters

listenerListener to be checked if it has been added.

Return

True if the certain listener has been added.

removeAllImpulseListeners

public function removeAllImpulseListeners(Void):Void

Removes all added ImpulseListeners from listening to any event.

connectExecutable

public function connectExecutable(executable:Executable):Void

Connect a certain executable to listen to the continous event.

Parameters

executableExecutable that should be connected

connectAllExecutables

public function connectAllExecutables(executables:Array):Void

Connects a list of Executables to be executed on the continous event.

Parameters

executablesList of Executables to be added.

getAllConnectedExecutables

public function getAllConnectedExecutables(Void):Array

Getter for the list of all connected Executables.

Return

List that contains all connected executables.

disconnectExecutable

public function disconnectExecutable(executable:Executable):Void

Disconnect a certain executable from listening to the Impulse.

Parameters

executableExecutable that should be disconnected

isExecutableConnected

public function isExecutableConnected(executable:Executable):Boolean

Checks if a certain Executable has been added as listener.

Parameters

executableExecutable to be checked if it has been added.

Return

True if the certain listener has been added.

disconnectAllExecutables

public function disconnectAllExecutables(Void):Void

Method to disconnect all connected Executables