Packagecom.developmentarc.framework.controllers.abstracts
Classpublic class AbstractTask
InheritanceAbstractTask Inheritance flash.events.EventDispatcher
ImplementsITask

The AbstractTask is the base class to extend all Tasks from. The TaskController does not require a Task to extend from AbstractTask, but looks for an ITask. The AbstractTask is provided as a starting point to define basic types, events and implementations of the required interface API.

The core structure of the Task follows the same basic design of a Flash Event. Like an Event, the Task has a default type and priority that is used by the TaskController and the TaskGroup to manage and organize the order of the active tasks.

See also

com.developmentarc.framework.controllers.TaskController
com.developmentarc.framework.datastructures.tasks.TaskGroup


Public Properties
 PropertyDefined by
  isBlocker : Boolean
[read-only] Determines if the Task blocks all other items in the TaskController.
AbstractTask
  phase : String
[read-only] Defines what phase the Task is currently in.
AbstractTask
  priority : uint
[read-only] Defines the priority value of the task defined at construction.
AbstractTask
  ready : Boolean
[read-only] Defines if the task is in a ready state.
AbstractTask
  selfOverride : Boolean
Defines if the Task is self-overriding when added to a TaskGroup or the TaskController.
AbstractTask
  taskOverrides : Array
[read-only] Defines the currently applied overrides for the Task.
AbstractTask
  type : String
[read-only] Defines the Task type.
AbstractTask
  uid : Object
[read-only] Stores the unique identification value of the Task which was defined at construction.
AbstractTask
Protected Properties
 PropertyDefined by
  currentOverrides : Array
Stores the list of overrides for the Task.
AbstractTask
  currentPhase : String
Stores the Task's internal current phase state value.
AbstractTask
Public Methods
 MethodDefined by
  
AbstractTask(type:String, priority:int = 5, uid:Object = null, selfOverride:Boolean = false, blocking:Boolean = false)
The Abstract Task constructor is used to define the base settings for the task.
AbstractTask
  
cancel():void
Called when a previously started Task needs to be cancelled.
AbstractTask
  
complete():void
Called when a previously started Task is completed.
AbstractTask
  
error():void
Called when a task recieves an error or generates an error.
AbstractTask
  
ignore():void
Called when a previously started Task needs to be set to ignore.
AbstractTask
  
inQueue():void
Called when a Task is added to a queue (TaskController or TaskGroup).
AbstractTask
  
Called when a task is waiting to be set to ready before starting.
AbstractTask
  
pause():void
Called when a previously started Task needs to be paused.
AbstractTask
  
start():void
Starts the Task's functionality.
AbstractTask
Events
 EventSummaryDefined by
    AbstractTask
    AbstractTask
    AbstractTask
    AbstractTask
    AbstractTask
    AbstractTask
    AbstractTask
Public Constants
 ConstantDefined by
  TASK_CREATED : String = "TASK_CREATED"
[static] Used as the flag for the current phase when a Task has been constructed.
AbstractTask
Property detail
currentOverridesproperty
protected var currentOverrides:Array

Stores the list of overrides for the Task.

currentPhaseproperty 
protected var currentPhase:String

Stores the Task's internal current phase state value. This property is protected and intended to be accessible from extended Classes. The value is publicly read-able via the phase getter.

isBlockerproperty 
isBlocker:Boolean  [read-only]

Determines if the Task blocks all other items in the TaskController. If the Task is set as a blocking task, the controller will load no more items from the queue until this Task is complete, cancelled or errors. The default is false.

Implementation
    public function get isBlocker():Boolean
phaseproperty 
phase:String  [read-only]

Defines what phase the Task is currently in. When a task is created the default phase is TASK_CREATED.

Implementation
    public function get phase():String
priorityproperty 
priority:uint  [read-only]

Defines the priority value of the task defined at construction. 0 is the highest priority, int.MAX_VALUE is the lowest.

Implementation
    public function get priority():uint
readyproperty 
ready:Boolean  [read-only]

Defines if the task is in a ready state.

Implementation
    public function get ready():Boolean
selfOverrideproperty 
selfOverride:Boolean  [read-write]

Defines if the Task is self-overriding when added to a TaskGroup or the TaskController. Tasks with matching uid's will be overridden.

Implementation
    public function get selfOverride():Boolean
    public function set selfOverride(value:Boolean):void

See also

taskOverridesproperty 
taskOverrides:Array  [read-only]

Defines the currently applied overrides for the Task. Overrides are used by the TaskController and the TaskGroup to determine if the current task is responsible for removing/canceling existing tasks in the system.

Implementation
    public function get taskOverrides():Array
typeproperty 
type:String  [read-only]

Defines the Task type.

Implementation
    public function get type():String
uidproperty 
uid:Object  [read-only]

Stores the unique identification value of the Task which was defined at construction. The uid is used by the TaskController and TaskGroup to determine what if the Task should be overridden well self override is set to true. Tasks with matching uid's will be overridden.

Implementation
    public function get uid():Object

See also

Constructor detail
AbstractTask()constructor
public function AbstractTask(type:String, priority:int = 5, uid:Object = null, selfOverride:Boolean = false, blocking:Boolean = false)

The Abstract Task constructor is used to define the base settings for the task. The only required argument is the type parameter which defines the Task type similar to an Event type.

Parameters
type:String — The Task type.
 
priority:int (default = 5) — The priority of the task, 0 is the highest priority, int.MAX_VALUE is the lowest.
 
uid:Object (default = null) — The unique identification id of the task used during the override process.
 
selfOverride:Boolean (default = false) — Defines of the task is self overriding.
 
blocking:Boolean (default = false) — Defines if the task is blocking.
Method detail
cancel()method
public function cancel():void

Called when a previously started Task needs to be cancelled. This is an optional method that must be overridden by the extending class to implement the cancel ability. By default the cancel() method sets the current phase to TaskEvent.TASK_CANCEL and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.cancel() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

complete()method 
public function complete():void

Called when a previously started Task is completed. This is an optional method that must be overridden by the extending class to implement the complete ability. By default the complete() method sets the current phase to TaskEvent.TASK_COMPLETE and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.complete() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

error()method 
public function error():void

Called when a task recieves an error or generates an error. By default the error() method sets the current phase to TaskEvent.TASK_ERROR and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.error() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

ignore()method 
public function ignore():void

Called when a previously started Task needs to be set to ignore. This is an optional method that must be overridden by the extending class to implement the cancel ability. By default the ignore() method sets the current phase to TaskEvent.TASK_IGNORED and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.ignore() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

inQueue()method 
public function inQueue():void

Called when a Task is added to a queue (TaskController or TaskGroup). This is an optional method that must be overridden by the extending class to implement the inQueue functionality. By default the inQueue() method sets the current phase to TaskEvent.TASK_QUEUED and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.inQueue() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

inWaitingForReady()method 
public function inWaitingForReady():void

Called when a task is waiting to be set to ready before starting. This is an optional method that must be overridden by the extending class to implement the waiting ability. By default the inWaitingForReady() method sets the current phase to TaskEvent.TASK_WAITING_FOR_READY and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.inWaitingForReady() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

pause()method 
public function pause():void

Called when a previously started Task needs to be paused. This is an optional method that must be overridden by the extending class to implement the pause ability. By default the pause() method sets the current phase to TaskEvent.TASK_PAUSE and then dispatches a TaskEvent informing any listener that the Task has now been paused.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.pause() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

start()method 
public function start():void

Starts the Task's functionality. When the TaskController or TaskGroup is ready to start the Task, the start() method is called. The AbstractTask sets the current Phase to TaskEvent.TASK_START and then dispatches a TaskEvent informing any listener that the Task has now been started.

When extending the AbstractTask, this method must be overridden to define the functionality of the task. It is recommended that calling super.start() is added as the last step of the overridden method so that the phase and TaskEvent is dispatched correctly.

Event detail
taskCancelevent 
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskCompelteevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskErrorevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskPauseevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskQueuedevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskReadyevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

taskStartevent  
Event object type: com.developmentarc.framework.controllers.events.TaskEvent

Constant detail
TASK_CREATEDconstant
public static const TASK_CREATED:String = "TASK_CREATED"

Used as the flag for the current phase when a Task has been constructed.