Packageorg.spicefactory.lib.task.util
Classpublic class DelegateTask
InheritanceDelegateTask Inheritance Task Inheritance flash.events.EventDispatcher

A Task implementation that delegates the actual execution of the operation. This may be useful if you want to integrate existing classes that cannot be retrofitted to be subclasses of Task, but need to act as children of a TaskGroup.



Public Properties
 PropertyDefined By
 Inheritedcancelable : Boolean
[read-only] Indicates whether this Task can be cancelled.
Task
 Inheriteddata : *
An arbitrary value associated with this Task.
Task
 Inheritedparent : TaskGroup
[read-only] The parent of this Task.
Task
 Inheritedrestartable : Boolean
[read-only] Indicates whether this Task can be restarted.
Task
 Inheritedroot : Task
[read-only] The root TaskGroup in case this Task is nested in one or more TaskGroups.
Task
 Inheritedskippable : Boolean
[read-only] Indicates whether this Task can be forced to skip to its final state.
Task
 Inheritedstate : TaskState
[read-only] The current state of this Task.
Task
 Inheritedsuspendable : Boolean
[read-only] Indicates whether this Task can be suspended.
Task
 Inheritedtimeout : uint
[read-only] The timeout for this Task in milliseconds.
Task
Public Methods
 MethodDefined By
  
DelegateTask(startFunction:Function, name:String = null, isRestartable:Boolean = true, timeout:uint = 0)
Creates a new instance.
DelegateTask
 Inherited
cancel():Boolean
Cancels this Task.
Task
  
markComplete():Boolean
Signals that this Task has completed.
DelegateTask
  
markError(message:String):Boolean
Signals an error condition and cancels the Task.
DelegateTask
 Inherited
resume():Boolean
Resumes this Task if it is suspended.
Task
  
setCancelFunction(cancelFunction:Function):void
Instruct the DelegateTask to execute the specified Function when it gets cancelled.
DelegateTask
  
setSkipFunction(skipFunction:Function):void
Instruct the DelegateTask to execute the specified Function when its finish method gets executed.
DelegateTask
  
setSupendFunctions(suspendFunction:Function, resumeFunction:Function):void
Instruct the DelegateTask to execute the specified Functions when it gets suspended and resumed.
DelegateTask
 Inherited
skip():Boolean
Forces this Task to move to its final state.
Task
 Inherited
start():Boolean
Starts this Task.
Task
 Inherited
suspend():Boolean
Suspends this Task.
Task
Protected Methods
 MethodDefined By
 Inherited
complete():Boolean
Signals that this Task has completed.
Task
 Inherited
doCancel():void
Called before the CANCEL event gets fired.
Task
 Inherited
doError(message:String):void
Called before the ERROR event gets fired.
Task
 Inherited
doResume():void
Called before the RESUME event gets fired.
Task
 Inherited
doSkip():void
Called after skip has been called but before the COMPLETE event gets fired.
Task
 Inherited
doStart():void
Called before the START event gets fired.
Task
 Inherited
doSuspend():void
Called before the SUSPEND event gets fired.
Task
 Inherited
doTimeout():void
Called before the ERROR event gets fired after a timeout occurred.
Task
 Inherited
error(message:String):Boolean
Signals an error condition and cancels the Task.
Task
 Inherited
setCancelable(value:Boolean):void
Specifies whether this Task can be cancelled.
Task
 Inherited
setName(name:String):void
Sets the name of this Task.
Task
 Inherited
setRestartable(value:Boolean):void
Specifies whether this Task can be restarted.
Task
 Inherited
setSkippable(value:Boolean):void
Specifies whether this Task can be forced to skip to its final state.
Task
 Inherited
setSuspendable(value:Boolean):void
Specifies whether this Task can be suspended.
Task
 Inherited
setTimeout(value:uint):void
Sets the timeout for this Task in milliseconds.
Task
Events
 Event Summary Defined By
 InheritedDispatched when a Task is cancelled.Task
 InheritedDispatched when a Task has completed its execution.Task
 InheritedDispatched when a Task has aborted due to an error condition.Task
 InheritedDispatched when a suspended Task is resumed.Task
 InheritedDispatched when a Task is started.Task
 InheritedDispatched when a Task is suspended.Task
Constructor Detail
DelegateTask()Constructor
public function DelegateTask(startFunction:Function, name:String = null, isRestartable:Boolean = true, timeout:uint = 0)

Creates a new instance. The properties cancelable, suspendable and finishable will initially be set to false until you set one of the corresponding delegate functions (like setCancelFunction).

Parameters
startFunction:Function — the function that gets executed when the Task is started
 
name:String (default = null) — an optioanal name for log output
 
isRestartable:Boolean (default = true) — whether this DelegateTask is restartable
 
timeout:uint (default = 0) — an optional timeout in milliseconds
Method Detail
markComplete()method
public function markComplete():Boolean

Signals that this Task has completed. If this method executes successfully the COMPLETE event will be fired.

Returns
Boolean — true if the Task successfully switched its internal state, false if otherwise
markError()method 
public function markError(message:String):Boolean

Signals an error condition and cancels the Task. If this method executes successfully the ERROR event will be fired.

Parameters

message:String — the error description

Returns
Boolean — true if the Task successfully switched its internal state, false if otherwise
setCancelFunction()method 
public function setCancelFunction(cancelFunction:Function):void

Instruct the DelegateTask to execute the specified Function when it gets cancelled. This method will automatically set the cancelable property to true.

Parameters

cancelFunction:Function — the Function to execute when this Task gets cancelled

setSkipFunction()method 
public function setSkipFunction(skipFunction:Function):void

Instruct the DelegateTask to execute the specified Function when its finish method gets executed. This method will automatically set the skippable property to true.

Parameters

skipFunction:Function — the Function to execute when the skip method of this Task gets executed

setSupendFunctions()method 
public function setSupendFunctions(suspendFunction:Function, resumeFunction:Function):void

Instruct the DelegateTask to execute the specified Functions when it gets suspended and resumed. This method will automatically set the suspendable property to true.

Parameters

suspendFunction:Function — the Function to execute when this Task is suspended
 
resumeFunction:Function — the Function to execute when this Task is resumed