Packagecom.bourre.commands
Classpublic class LoopCommand
InheritanceLoopCommand Inheritance AbstractSyncCommand Inheritance AbstractCommand
ImplementsASyncCommandListener, Cancelable, Suspendable, TickListener

Player version: Flash Player 9.0
Language version: ActionScript 3.0

A LoopCommand wrap a loop statement within a command. Loop are strecthed over time using functionnalities of a TickBeacon object. According to the maximum execution time limit of this command the maximum amout of iteration will be performed for each step since the step execution time exceed the maximum execution time.

For informations and examples on these classes see the How to use LoopCommand and IterationCommand document.

See also

IterationCommand.html


Protected Properties
 PropertyDefined by
 Inherited_bIsRunning : Boolean
A boolean value which indicates if this command is currently processing.
AbstractSyncCommand
 Inherited_eOnCommandEnd : BasicEvent
An event instance used as event object when dispatching the onCommandEnd event to its listener.
AbstractSyncCommand
 Inherited_oEB : EventBroadcaster
The internal event broadcaster.
AbstractSyncCommand
 Inherited_owner : Plugin
A reference to the plugin owner of this command.
AbstractCommand
Public Methods
 MethodDefined by
  
LoopCommand(command:IterationCommand, iterationLimit:Number)
Creates a new LoopCommand object which will handle the passed-in IterationCommand
LoopCommand
 Inherited
addASyncCommandListener(listener:ASyncCommandListener, ... rest):Boolean
Adds the passed-in listener as listener for the onCommandEnd event of this command.
AbstractSyncCommand
  
Adds the passed-in listener as listener for this command's events.
LoopCommand
  
cancel():void
Attempts to cancel execution of this task.
LoopCommand
  
execute(e:Event = null):void
Resets and then start the loop command process.
LoopCommand
 Inherited
Fires the onCommandEnd event to the listeners of this command.
AbstractSyncCommand
 Inherited
Returns the exclusive logger object owned by the plugin.
AbstractCommand
 Inherited
getModel(key:String):AbstractModel
Returns a reference to the model AbstractModel.
AbstractCommand
 Inherited
Returns a reference to the owner of this command.
AbstractCommand
 Inherited
getView(key:String):AbstractView
Returns a reference to the view AbstractView.
AbstractCommand
  
isCancelled():Boolean
Returns true if the loop process have been canceled by the user.
LoopCommand
  
isDone():Boolean
Returns true if the loop process have been completed.
LoopCommand
 Inherited
isModelRegistered(key:String):Boolean
Check if a model AbstractModel is registered with passed key in owner's ModelLocator.
AbstractCommand
 Inherited
isRunning():Boolean
Returns true if this command is currently processing.
AbstractSyncCommand
 Inherited
isViewRegistered(key:String):Boolean
Check if a view AbstractView is registered with passed key in owner's ViewLocator.
AbstractCommand
  
onCommandEnd(e:Event):void
Called at the end of another loop command.
LoopCommand
  
onTick(e:Event = null):void
Process the loop.
LoopCommand
 Inherited
Removes the passed-in listener for listening the onCommandEnd event of this command.
AbstractSyncCommand
  
Removes the passed-in listener as listener for this command's events.
LoopCommand
  
reset():void
Resets the state of this command.
LoopCommand
 Inherited
run():void
Implementation of the Runnable interface, a call to run() is equivalent to a call to execute without argument.
AbstractSyncCommand
  
Defines on which beacon the loop command will perform its operation.
LoopCommand
  
setOwner(owner:Plugin):void
LoopCommand
  
start():void
Starts or restarts the loop process.
LoopCommand
  
stop():void
Stops the loop process.
LoopCommand
 Inherited
toString():String
Returns the string representation of the object.
AbstractSyncCommand
Protected Methods
 MethodDefined by
  
fireOnIterationEvent(i:Number, o:*):void
Fires the onLoopStart event to the internal IterationCommand.
LoopCommand
  
fireOnLoopCancelEvent(n:Number):void
Fires the onLoopCancel event to its listeners.
LoopCommand
  
fireOnLoopEndEvent(n:Number):void
Fires the onLoopEnd event to its listeners.
LoopCommand
  
fireOnLoopProgressEvent(n:Number):void
Fires the onLoopProgresst event to its listeners.
LoopCommand
  
fireOnLoopStartEvent(n:Number):void
Fires the onLoopStart event to its listeners.
LoopCommand
  
fireOnLoopStopEvent(n:Number):void
Fires the onLoopStop event to its listeners.
LoopCommand
 Inherited
firePrivateEvent(e:Event):void
Fires a private event directly on this command's owner.
AbstractCommand
Public Constants
 ConstantDefined by
  DEFAULT_ITERATION_TIME_LIMIT : Number = 15
[static] Default execution time limit by loop iterations group
LoopCommand
  NO_LIMIT : Number = Infinity
[static] Defines an unlimited execution time for loop iterations.
LoopCommand
 InheritedonCommandEndEVENT : String = "onCommandEnd"
[static] Name of the event dispatched at the end of the command's process.
AbstractSyncCommand
  onLoopCancelEVENT : String = "onLoopCancel"
[static] Name of the event dispatched on user cancelation.
LoopCommand
  onLoopEndEVENT : String = "onLoopEnd"
[static] Name of the event dispatched at the end of the command's process.
LoopCommand
  onLoopProgressEVENT : String = "onLoopProgress"
[static] Name of the event dispatched at each step of computation.
LoopCommand
  onLoopStartEVENT : String = "onLoopStart"
[static] Name of the event dispatched at the start of the command's process.
LoopCommand
  onLoopStopEVENT : String = "onLoopStop"
[static] Name of the event dispatched at the stop of the command's process.
LoopCommand
Constructor detail
LoopCommand()constructor
public function LoopCommand(command:IterationCommand, iterationLimit:Number)

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates a new LoopCommand object which will handle the passed-in IterationCommand

Parameters
command:IterationCommand — iteration command which will be called during the loop, it also provide the iterator the loop command will use
 
iterationLimit:Number — maximum execution time for each step of the loop command process
Method detail
addLoopCommandListener()method
public function addLoopCommandListener(listener:LoopCommandListener):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Adds the passed-in listener as listener for this command's events.

Parameters
listener:LoopCommandListener — listener to be added

Returns
Boolean
cancel()method 
public function cancel():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run.

After this method returns, subsequent calls to isRunning will always return false. Subsequent calls to run will always fail with an exception. Subsequent calls to cancel will always failed with the throw of an exception.


Throws
IllegalStateException — if the cancel method have been called wheras the operation have been already cancelled
execute()method 
public override function execute(e:Event = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Resets and then start the loop command process.

The command cannot be executed after a call to the cancel method. If a call to execute is done after the command be canceled the function fail and throw an error

Parameters
e:Event (default = null) — event object to initialise the command (not use)

Throws
IllegalStateException — if the execute method have been called wheras the operation have been already cancelled
fireOnIterationEvent()method 
protected function fireOnIterationEvent(i:Number, o:*):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopStart event to the internal IterationCommand.

Parameters
i:Number — current iteration number
 
o:* — value retreived from the iterator next method
fireOnLoopCancelEvent()method 
protected function fireOnLoopCancelEvent(n:Number):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopCancel event to its listeners.

Parameters
n:Number — iterations performed until the cancelation
fireOnLoopEndEvent()method 
protected function fireOnLoopEndEvent(n:Number):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopEnd event to its listeners.

Parameters
n:Number — iterations performed until the end
fireOnLoopProgressEvent()method 
protected function fireOnLoopProgressEvent(n:Number):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopProgresst event to its listeners.

Parameters
n:Number — iterations performed until the call
fireOnLoopStartEvent()method 
protected function fireOnLoopStartEvent(n:Number):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopStart event to its listeners.

Parameters
n:Number — iterations performed until the restart
fireOnLoopStopEvent()method 
protected function fireOnLoopStopEvent(n:Number):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Fires the onLoopStop event to its listeners.

Parameters
n:Number — iterations performed until the stop
isCancelled()method 
public function isCancelled():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if the loop process have been canceled by the user.

Returns
Booleantrue if the loop process have been canceled by the user
isDone()method 
public function isDone():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if the loop process have been completed.

Returns
Booleantrue if the loop process have been completed
onCommandEnd()method 
public function onCommandEnd(e:Event):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Called at the end of another loop command. The LoopCommand class implements ASyncCommandListener in order to provide a way to automatically chain several commands together.

Parameters
e:Event — event object dispatched by the asynchronous command
onTick()method 
public function onTick(e:Event = null):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Process the loop. At each call of this function a real loop statement is performed until its execution time go past the maximum execution time defined for this command.

Parameters
e:Event (default = null) — event object dispatched by the beacon
removeLoopCommandListener()method 
public function removeLoopCommandListener(listener:LoopCommandListener):Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes the passed-in listener as listener for this command's events.

Parameters
listener:LoopCommandListener — listener to be removed

Returns
Boolean
reset()method 
public function reset():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Resets the state of this command. A loop command cannot be reset while running. If a call to the reset is done while the command is running, the call fail with an error.


Throws
IllegalStateException — Can't reset an operation currently running.
setFrameBeacon()method 
public function setFrameBeacon(beacon:TickBeacon):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Defines on which beacon the loop command will perform its operation. It allow to the user to control the speed at which execution steps will be called.

Parameters
beacon:TickBeacon — beacon object onto which the command will run
setOwner()method 
public override function setOwner(owner:Plugin):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Parameters
owner:Plugin
start()method 
public function start():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Starts or restarts the loop process. The process can be started only if there is a valid IterationCommand and if the command haven't be canceled or completed.


Throws
IllegalStateException — Can't start a command which has no specified iteration command
 
IllegalStateException — Can't start a canceled or completed command
stop()method 
public function stop():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Stops the loop process. Command could be stop only when it is running.

Constant detail
DEFAULT_ITERATION_TIME_LIMITconstant
public static const DEFAULT_ITERATION_TIME_LIMIT:Number = 15

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Default execution time limit by loop iterations group

NO_LIMITconstant 
public static const NO_LIMIT:Number = Infinity

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Defines an unlimited execution time for loop iterations.

onLoopCancelEVENTconstant 
public static const onLoopCancelEVENT:String = "onLoopCancel"

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Name of the event dispatched on user cancelation.

onLoopEndEVENTconstant 
public static const onLoopEndEVENT:String = "onLoopEnd"

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Name of the event dispatched at the end of the command's process.

onLoopProgressEVENTconstant 
public static const onLoopProgressEVENT:String = "onLoopProgress"

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Name of the event dispatched at each step of computation.

onLoopStartEVENTconstant 
public static const onLoopStartEVENT:String = "onLoopStart"

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Name of the event dispatched at the start of the command's process.

onLoopStopEVENTconstant 
public static const onLoopStopEVENT:String = "onLoopStop"

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Name of the event dispatched at the stop of the command's process.