ProcessGroup
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.process |
| Inherits from: | Process < RemovableEventDispatcher < EventDispatcher |
| Known subclasses: | |
| Version: | 09/06/09 |
| Author: | Aaron Clinger |
| Classpath: | org.casalib.process.ProcessGroup |
| File last modified: | Sunday, 06 September 2009, 09:13:14 |
Manages and threads processes.
Example:
-
package { import fl.motion.easing.Linear; import org.casalib.display.CasaMovieClip; import org.casalib.display.CasaSprite; import org.casalib.events.ProcessEvent; import org.casalib.process.ProcessGroup; import org.casalib.transitions.PropertyTween; public class MyExample extends CasaMovieClip { protected var _processGroup:ProcessGroup; public function MyExample() { super(); this._processGroup = new ProcessGroup(); this._processGroup.addEventListener(ProcessEvent.COMPLETE, this._onProcessComplete); var i:int = -1; var box:CasaSprite; while (++i < 10) { box = new CasaSprite(); box.y = 30 * i; box.graphics.beginFill(0xFF00FF); box.graphics.drawRect(0, 0, 25, 25); box.graphics.endFill(); this.addChild(box); this._processGroup.addProcess(new PropertyTween(box, 'x', Linear.easeNone, 500, 1)); } this._processGroup.start(); } protected function _onProcessComplete(e:ProcessEvent):void { this._processGroup.destroyProcesses(); this._processGroup.destroy(); trace("Done!"); } } }
Summary
Constructor
Constants
- MAX_THREADS : uint
- The maximum amount of threads for a ProcessGroup instance.
Class properties
- NORM_THREADS : uint
- The default amount of threads for all ProcessGroup instances.
Class properties inherited from Process
Instance properties
- autoStart : Boolean
- Instructs the ProcessGroup to start automatically if it contains an incomplete Process or if an incomplete is added.
- processes : Array
- The processes that compose the group.
- queuedProcesses : Array
- The processes that are neither complete or running.
- runningProcesses : Array
- The processes that are currently running.
- incompletedProcesses : Array
- The processes that have not completed.
- completedProcesses : Array
- The processes that have completed.
- threads : uint
- The number of simultaneous processes to run at once.
Instance properties inherited from Process
Instance properties inherited from RemovableEventDispatcher
Instance methods
- start : void
- stop : void
- addProcess (process:Process) : void
- Adds a process to be threaded and run by the ProcessGroup.
- removeProcess (process:Process) : void
- Removes a process from the ProcessGroup.
- hasProcess (process:Process) : Boolean
- Determines if this ProcessGroup contains a specific process.
- destroyProcesses : void
- Calls destroy on all processes in the group and removes them from the ProcessGroup.
- destroy : void
Instance methods inherited from RemovableEventDispatcher
Constructor
ProcessGroup
public function ProcessGroup (
)
Creates a new ProcessGroup.
Constants
MAX_THREADS
public static const MAX_THREADS:uint = uint.MAX_VALUE
(read)
The maximum amount of threads for a ProcessGroup instance. Use this value if you wish to disable threading.
Class properties
NORM_THREADS
public static NORM_THREADS:uint = 1
(read,write)
The default amount of threads for all ProcessGroup instances.
Instance properties
autoStart
public autoStart:Boolean
(read,write)
completedProcesses
public completedProcesses:Array
(read)
The processes that have completed.
incompletedProcesses
public incompletedProcesses:Array
(read)
The processes that have not completed.
processes
public processes:Array
(read)
The processes that compose the group.
queuedProcesses
public queuedProcesses:Array
(read)
The processes that are neither complete or running.
runningProcesses
public runningProcesses:Array
(read)
The processes that are currently running.
threads
public threads:uint
(read,write)
The number of simultaneous processes to run at once.
Instance methods
addProcess
Adds a process to be threaded and run by the ProcessGroup.
Parameters:
process:
The process to be added and run by the group.
Usage note:
- You can add a different instance of ProcessGroup to another ProcessGroup.
Throws:
- Error if you try add the same Process to itself.
destroyProcesses
public function destroyProcesses (
) : void
Calls destroy on all processes in the group and removes them from the ProcessGroup.
hasProcess
Determines if this ProcessGroup contains a specific process.
Parameters:
process:
The process to search for.
Returns:
- Returns
trueif the ProcessGroup contains the process; otherwisefalse.
removeProcess
Removes a process from the ProcessGroup.
Parameters:
process:
The process to be removed.