LoopCommand
| Kind of class: | public class |
|---|---|
| Package: | com.bourre.commands |
| Inherits from: | AbstractSyncCommand < AbstractCommand |
| Implements: |
|
| Author: | Cédric Néhémie |
| Classpath: | com.bourre.commands.LoopCommand |
| File last modified: | Monday, 24 November 2008, 11:36:52 |
A
are strecthed over time using functionnalities of a
the maximum amout of iteration will be performed for each step since the
step execution time exceed the maximum execution time.
LoopCommand wrap a loop statement within a command. Loopare strecthed over time using functionnalities of a
TickBeaconobject. According to the maximum execution time limit of this commandthe 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:
Summary
Constructor
- LoopCommand (command:IterationCommand, iterationLimit:Number = DEFAULT_ITERATION_TIME_LIMIT)
- Creates a new LoopCommand object which will handle
Constants
- DEFAULT_ITERATION_TIME_LIMIT : Number
- Default execution time limit by loop iterations group
- NO_LIMIT : Number
- Defines an unlimited execution time for loop iterations.
Instance methods
- execute (e:Event = null) : void
- Resets and then start the loop command process.
- cancel : void
- Attempts to cancel execution of this task.
- isCancelled : Boolean
- Returns true if the loop process have been
- isDone : Boolean
- Returns true if the loop process have been
- reset : void
- Resets the state of this command.
- start : void
- Starts or restarts the loop process.
- stop : void
- Stops the loop process.
- setOwner (owner:Plugin) : void
- setFrameBeacon (beacon:TickBeacon) : void
- Defines on which beacon the loop command will perform
- addLoopCommandListener (listener:LoopCommandListener) : Boolean
- Adds the passed-in listener as listener for this command's events.
- removeLoopCommandListener (listener:LoopCommandListener) : Boolean
- Removes the passed-in listener as listener for this command's events.
Event handlers
- onLoopStartEVENT : String
- Name of the event dispatched at the start of the command's process.
- onLoopStopEVENT : String
- Name of the event dispatched at the stop of the command's process.
- onLoopProgressEVENT : String
- Name of the event dispatched at each step of computation.
- onLoopEndEVENT : String
- Name of the event dispatched at the end of the command's process.
- onLoopCancelEVENT : String
- Name of the event dispatched on user cancelation.
- onTick (e:Event = null) : void
- Process the loop.
- onCommandEnd (e:Event) : void
- Called at the end of another loop command.
Constructor
LoopCommand
public function LoopCommand (
command:IterationCommand,
iterationLimit:Number = DEFAULT_ITERATION_TIME_LIMIT)
Creates a new
the passed-in
LoopCommand object which will handlethe passed-in
IterationCommand Parameters:
command :
iteration command which will be called
during the loop, it also provide the
iterator the loop command will use
during the loop, it also provide the
iterator the loop command will use
iterationLimit:
maximum execution time for each step of
the loop command process
the loop command process
Constants
DEFAULT_ITERATION_TIME_LIMIT
public static const DEFAULT_ITERATION_TIME_LIMIT:Number = 15
(read)
Default execution time limit by loop iterations group
NO_LIMIT
public static const NO_LIMIT:Number = Number.POSITIVE_INFINITY
(read)
Defines an unlimited execution time for loop iterations.
Instance methods
addLoopCommandListener
Adds the passed-in listener as listener for this command's events.
Parameters:
listener:
listener to be added
cancel
public function cancel (
) : void
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.
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 isRunningwill always return false. Subsequent calls torun will always fail with an exception. Subsequent
calls to cancel will always failed with the throw
of an exception.
Throws:
- {VISDOC_LINK_0}
IllegalStateException— if thecancelmethod have been called wheras the operation have been already
cancelled
execute
override public function execute (
e:Event = null) : void
Resets and then start the loop command process.
the function fail and throw an error
The command cannot be executed after a call to
the cancel method. If a call to
executeis done after the command be canceled
the function fail and throw an error
Parameters:
e:
event object to initialise the command (not use)
Throws:
- {VISDOC_LINK_0}
IllegalStateException— if theexecutemethod have been called wheras the operation have been already
cancelled
Overrides:
- AbstractSyncCommand.execute
isCancelled
public function isCancelled (
) : Boolean
Returns
canceled by the user.
true if the loop process have beencanceled by the user.
Returns:
-
trueif the loop process have been
canceled by the user
isDone
public function isDone (
) : Boolean
Returns
completed.
true if the loop process have been completed.
Returns:
-
trueif the loop process have been
completed
removeLoopCommandListener
Removes the passed-in listener as listener for this command's events.
Parameters:
listener:
listener to be removed
reset
public function reset (
) : void
Resets the state of this command. A loop command cannot be reset
while running. If a call to the
while the command is running, the call fail with an error.
while running. If a call to the
reset is donewhile the command is running, the call fail with an error.
Throws:
- {VISDOC_LINK_0}
IllegalStateException— Can't reset an
operation currently running.
setFrameBeacon
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.
its operation. It allow to the user to control the
speed at which execution steps will be called.
Parameters:
beacon:
beacon object onto which the command
will run
will run
setOwner
Overrides:
- AbstractSyncCommand.setOwner
start
public function start (
) : void
Starts or restarts the loop process.
The process can be started only if there is a valid
haven't be canceled or completed.
The process can be started only if there is a valid
IterationCommand and if the command haven't be canceled or completed.
Throws:
- {VISDOC_LINK_0}
IllegalStateException— Can't start
a command which has no specified iteration command - {VISDOC_LINK_1}
IllegalStateException— Can't start a
canceled or completed command
stop
public function stop (
) : void
Stops the loop process. Command could be
stop only when it is running.
stop only when it is running.
Event handlers
onCommandEnd
public function onCommandEnd (
e:Event) : void
Called at the end of another loop command.
The
provide a way to automatically chain several
commands together.
The
LoopCommand class implements ASyncCommandListener in order toprovide a way to automatically chain several
commands together.
Parameters:
e:
event object dispatched by the asynchronous command
Specified by:
onLoopCancelEVENT
public static const onLoopCancelEVENT:String = "onLoopCancel"
(read)
Name of the event dispatched on user cancelation.
onLoopEndEVENT
public static const onLoopEndEVENT:String = "onLoopEnd"
(read)
Name of the event dispatched at the end of the command's process.
onLoopProgressEVENT
public static const onLoopProgressEVENT:String = "onLoopProgress"
(read)
Name of the event dispatched at each step of computation.
onLoopStartEVENT
public static const onLoopStartEVENT:String = "onLoopStart"
(read)
Name of the event dispatched at the start of the command's process.
onLoopStopEVENT
public static const onLoopStopEVENT:String = "onLoopStop"
(read)
Name of the event dispatched at the stop of the command's process.
onTick
public function onTick (
e:Event = null) : void
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.
a real loop statement is performed until its
execution time go past the maximum execution time
defined for this command.
Parameters:
e:
event object dispatched by the beacon
Specified by: