Packageorg.springextensions.actionscript.core.task
SVN browsingITask.as
FisheyeITask.as
Interfacepublic interface ITask extends ICommand, IOperation, flash.events.IEventDispatcher
SubinterfacesIForBlock, IIfElseBlock, ITransaction, IWhileBlock
ImplementorsAbstractTaskBlock, Task, TaskFlowControlCommand

Describes an object that is enable to execute a collection of ICommands, both in sequence and in parallel, including simple flowcontrol logic such as if, else, while and for.

This is a so-called 'fluent' interface allowing method calls to be 'chained', like this:

  var task:ITask = new Task();
  task.next(new Command1()).next(new Command2()).and(new Command3()).and(new Command4()).execute();
  

Because ITask itself is an extension of the ICommand interface it is possible to nest task executions, like this:

  var task1:ITask = new Task();
  task1.next(new Command1()).next(new Command2()).and(new Command3()).and(new Command4());
  var task2:ITask = new Task();
  task2.next(task1).next(new Command5()).execute();
  

Note: An ITask can only be nested in one other execution chain. Do not re-use instances among different ITasks.



Documentation reference: tasks


Public Properties
 PropertyDefined by
  context : Object
An anonymous object that can be used to store values that can be accessed by other client code to pass around these values between commands.
ITask
 Inheritederror : *
The error of this operation or null if no error occurred during this operation.
IOperation
  parent : ITask
If the current ITask is part of the execution chain of another ITask, this property will have a reference to that instance.
ITask
 Inheritedresult : *
The result of this operation or null if the operation does not have a result.
IOperation
 Inheritedtimeout : int
The timeout in milliseconds.
IOperation
Public Methods
 MethodDefined by
 Inherited
addCompleteListener(listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Convenience method for adding a listener to the OperationEvent.COMPLETE event.
IOperation
 Inherited
addErrorListener(listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Convenience method for adding a listener to the OperationEvent.ERROR event.
IOperation
 Inherited
addTimeoutListener(listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Convenience method for adding a listener to the OperationEvent.TIMEOUT event.
IOperation
  
and(command:ICommand):ITask
Adds an ICommand that will be executed in parallel.
ITask
  
Switches the current IIfElseBlock control flow to its else block.
ITask
  
Closes the current ITaskBlock.
ITask
 Inherited
execute():*
Executes the command.
ICommand
  
Stops the execution chain completely.
ITask
  
for_(count:uint, countProvider:ICountProvider = null, forBlock:IForBlock = null):IForBlock
Adds a repeating execution block which will be executed a specified number of times, determined by the specified count or ICountProvider parameters.
ITask
  
if_(condition:IConditionProvider = null, ifElseBlock:IIfElseBlock = null):IIfElseBlock
Adds a conditional execution block to the current ITask which will only be executed if the specified IConditionProvider return true.
ITask
  
next(command:ICommand):ITask
Adds an ICommand that will be executed in sequence.
ITask
  
pause(duration:uint, pauseCommand:ICommand = null):ITask
Pauses the current ITask for the specified amount of milliseconds.
ITask
 Inherited
removeCompleteListener(listener:Function, useCapture:Boolean = false):void
Convenience method for removing a listener from the OperationEvent.COMPLETE event.
IOperation
 Inherited
removeErrorListener(listener:Function, useCapture:Boolean = false):void
Convenience method for removing a listener from the OperationEvent.ERROR event.
IOperation
 Inherited
removeTimeoutListener(listener:Function, useCapture:Boolean = false):void
Convenience method for removing a listener from the OperationEvent.TIMEOUT event.
IOperation
  
reset(doHardReset:Boolean = false):ITask
Restarts the execution of the current ITask.
ITask
  
while_(condition:IConditionProvider = null, whileBlock:IWhileBlock = null):IWhileBlock
Adds a repeating execution block which will be executed until the specified IConditionProvider returns false.
ITask
Events
 EventSummaryDefined by
 Inherited Dispatched when the current IOperation completed successfully.IOperation
 Inherited Dispatched when the current IOperation encountered an error.IOperation
 Inherited Dispatched when the current IOperation timed out.IOperation
   Dispatched when the task is aborted.ITask
   Dispatched after the task has executed an ICommand.ITask
   Dispatched before the task executes an ICommand.ITask
   Dispatched when the task is completed.ITask
Property detail
contextproperty
context:Object  [read-write]

An anonymous object that can be used to store values that can be accessed by other client code to pass around these values between commands.

Implementation
    public function get context():Object
    public function set context(value:Object):void
parentproperty 
parent:ITask  [read-write]

If the current ITask is part of the execution chain of another ITask, this property will have a reference to that instance.

Implementation
    public function get parent():ITask
    public function set parent(value:ITask):void
Method detail
and()method
public function and(command:ICommand):ITask

Adds an ICommand that will be executed in parallel.

Parameters
command:ICommand — The specified ICommand

Returns
ITask — A reference to the current ITask
else_()method 
public function else_():IIfElseBlock

Switches the current IIfElseBlock control flow to its else block.

Returns
IIfElseBlock — The current IIfElseBlock instance.
end()method 
public function end():ITask

Closes the current ITaskBlock.

Returns
ITask — The current ITask.
exit()method 
public function exit():ITask

Stops the execution chain completely.

Returns
ITask — The current ITask.
for_()method 
public function for_(count:uint, countProvider:ICountProvider = null, forBlock:IForBlock = null):IForBlock

Adds a repeating execution block which will be executed a specified number of times, determined by the specified count or ICountProvider parameters.

Parameters
count:uint — The specified ICountProvider. This argument is ignored if the forBlock argument is not null.
 
countProvider:ICountProvider (default = null) — Optional IForBlock instance, if this is null a new instance will be created.
 
forBlock:IForBlock (default = null)

Returns
IForBlock — The new IForBlock instance.
if_()method 
public function if_(condition:IConditionProvider = null, ifElseBlock:IIfElseBlock = null):IIfElseBlock

Adds a conditional execution block to the current ITask which will only be executed if the specified IConditionProvider return true.

Parameters
condition:IConditionProvider (default = null) — The specified IConditionProvider. This argument is ignored if the ifElseBlock argument is not null.
 
ifElseBlock:IIfElseBlock (default = null) — Optional IIfElseBlock instance, if this is null a new instance will be created.

Returns
IIfElseBlock — The new IIfElseBlock instance.
next()method 
public function next(command:ICommand):ITask

Adds an ICommand that will be executed in sequence.

Parameters
command:ICommand — The specified ICommand

Returns
ITask — A reference to the current ITask
pause()method 
public function pause(duration:uint, pauseCommand:ICommand = null):ITask

Pauses the current ITask for the specified amount of milliseconds.

Parameters
duration:uint — The specified amount of milliseconds
 
pauseCommand:ICommand (default = null)ICommand instance to be used as a pause command, if this parameter is not null the duration parameter is ignored.

Returns
ITask — The current ITask.
reset()method 
public function reset(doHardReset:Boolean = false):ITask

Restarts the execution of the current ITask.

Parameters
doHardReset:Boolean (default = false)

Returns
ITask — The current ITask.
while_()method 
public function while_(condition:IConditionProvider = null, whileBlock:IWhileBlock = null):IWhileBlock

Adds a repeating execution block which will be executed until the specified IConditionProvider returns false.

Parameters
condition:IConditionProvider (default = null) — The specified IConditionProvider. This argument is ignored if the whileBlock argument is not null.
 
whileBlock:IWhileBlock (default = null) — Optional IWhileBlock instance, if this is null a new instance will be created.

Returns
IWhileBlock — The new IWhileBlock instance.
Event detail
taskAbortedevent 
Event object type: org.springextensions.actionscript.core.task.event.TaskEvent
TaskEvent.type property = org.springextensions.actionscript.core.task.event.TaskEvent.TASK_ABORTED

Dispatched when the task is aborted.

taskAfterExecuteCommandevent  
Event object type: org.springextensions.actionscript.core.task.event.TaskEvent
TaskEvent.type property = org.springextensions.actionscript.core.task.event.TaskEvent.AFTER_EXECUTE_COMMAND

Dispatched after the task has executed an ICommand.

taskBeforeExecuteCommandevent  
Event object type: org.springextensions.actionscript.core.task.event.TaskEvent
TaskEvent.type property = org.springextensions.actionscript.core.task.event.TaskEvent.BEFORE_EXECUTE_COMMAND

Dispatched before the task executes an ICommand.

taskCompleteevent  
Event object type: org.springextensions.actionscript.core.task.event.TaskEvent
TaskEvent.type property = org.springextensions.actionscript.core.task.event.TaskEvent.TASK_COMPLETE

Dispatched when the task is completed.