Access keys

FlowController

Kind of class: class
Inherits from: Dispatcher
Version: 24 July 2005
Author: Arthur Clemens
Classpath: data.tree.FlowController
File last modified: Wednesday, 27 July 2005, 00:09:41
FlowController runs through a series of instructions - represented by a Tree of FlowTreeNodes.
To do:
Document evaluation
Events broadcast to listeners:
FlowControllerEvent with type: CONDITION When a condition is found.
FlowControllerEvent with type: ACTION When an action is.
FlowControllerEvent with type: AWAIT When an await is found.
FlowControllerEvent with type: EXIT When an exit instruction is found.
FlowControllerEvent with type: ACTION When an action is found.
FlowControllerEvent with type: AWAIT When an await instruction is found.

Constructor

FlowController

function FlowController (
inActionObject:Object)
Creates a FlowController, with the FlowController's Tree. This Tree uses nodes of type FlowTreeNode.
Parameters:
inActionObject:
the object to perform methods, see setActionObject
Example:
In a FlowController subclass (when using data.filedatatransform.TextFile2Tree):
function MyFlowController (inActionObject:Object, inDataUrl:String)
{
    super(inActionObject);
    new TextFile2Tree(inDataUrl, this, tree);
}

private function onTextFile2TreeFinished (inEvent:TextFile2TreeEvent) : Void
{
    run();
}

Instance properties

tree

tree:Tree
(read)
The Tree object used by FlowController.

Instance methods

evaluate

function evaluate (
inCondition:String) : Void

run

function run (
) : Void
First creates an enumerator if not defined before.
Calls the next instruction of the enumerator. The type of instruction is defined by the attribute FlowTreeNode.type. The value of the instruction type determines the next steps:
  • In case of an action instruction
    • If an action object has been set and a FlowTreeNode.method is passed in the instruction, this method is called on the action object; then the next run is called.
    • A FlowControllerEvent.ACTION message is sent and the next run is called.
  • In case of a condition
    • If an action object has been set and a FlowTreeNode.method is passed in the instruction, this method is called on the action object.
    • A FlowControllerEvent.CONDITION message is sent and further running is deferred. The receiving object is responsible for interpreting the condition. To continue the flow, the object should call runResult or run.
  • In case of an await:
    • If an action object has been set and a method is passed in the instruction, this method is called on the action object (no message is sent).
    • A FlowControllerEvent.AWAIT message is sent.
  • In case of an exit instruction, an FlowControllerEvent.EXIT message is sent.
  • In all other cases (when no type is given) the next run is called.
Events broadcast to listeners:
FlowControllerEvent with type: CONDITION When a condition is found.
FlowControllerEvent with type: ACTION When an action is.
FlowControllerEvent with type: AWAIT When an await is found.
FlowControllerEvent with type: EXIT When an exit instruction is found.
Implementation note:
Events are sent by the invoked method update.

runResult

function runResult (
inResult:String) : Void
Calls the next instruction with the action that corresponds to the key inResult.
Example:
With the following instruction:
question1, text="Which square is the red one?", type=condition, red=question2, green=question3
when runResult is called with the result "green", the next instruction question3 is called.

In the FlowController owner:
private function onEventButtonPress (inEvent:EventButtonEvent) : Void
{
    var answer:String = inEvent.buttonName;
    mFlowController.runResult(answer);
}

setActionObject

function setActionObject (
inActionObject:Object) : Void
Stores the object that performs methods that are passed with the FlowTreeNode.method instruction attribute.
Parameters:
inActionObject:
the object to perform methods