Package | com.eqsim.FStEng |
Class | public class Transition |
Inheritance | Transition ![]() |
This class is used to create transitions. In previous versions of the state engine, we required the developer to specify the relation of the source and target (siblings, ancestors, etc.), but we have removed that restriction in version 3. The processing is hidden from the developer so that making and using transitions is as easy as possible.
Essentially, when one creates a Transition, one only has to supply the target state ID, and the code figures out the path required to accomplish the transition.
The code figures out the path from the source to the target, by default, at the moment before the state engine
is activated. This operation, therefore, can delay the activation of the engine proportional to the number and complexity
of the state transitions. To eliminate this delay, the developer can invoke myStateEnginePtr.prepareNetwork()
at
any time that all the states and transitions have been defined. Then, when myStateEnginePtr.active = true
is invoked,
the engine checks to see if the network has been prepared, and, if so, does not have to compute the transition paths again.
Transitions can point to themselves -- we call these "transitions to self." This class permits developers to specify how many levels to exit before returning to the same state (see the final argument of the constructor), for transitions to self.
Property | Defined By | ||
---|---|---|---|
source : State
Pointer to the source State (HState or HStateC). | Transition | ||
stPath : Array
An array consisting of state identifiers from the LCA to the target state. | Transition | ||
targetID : String
ID of the target state. | Transition | ||
upLvls : int
The number of levels in the state network to go up to reach the Least Common Ancestor. | Transition |
Method | Defined By | ||
---|---|---|---|
Transition(src:State, tid:String, tfn:Function = null, doHistory:Boolean = false, upLevelsForExternalTransition:uint = 0)
Creates a Transition instance. | Transition |
source | property |
public var source:State
Pointer to the source State (HState or HStateC).
stPath | property |
public var stPath:Array
An array consisting of state identifiers from the LCA to the target state.
targetID | property |
public var targetID:String
ID of the target state. Identifier must be unique across all states in the state engine.
upLvls | property |
public var upLvls:int
The number of levels in the state network to go up to reach the Least Common Ancestor.
Transition | () | Constructor |
public function Transition(src:State, tid:String, tfn:Function = null, doHistory:Boolean = false, upLevelsForExternalTransition:uint = 0)
Creates a Transition instance.
Transition instances are used to connect states. Transitions are triggered by events, but that information is stored in the State to which the Transition is attached. The transition permits one to invoke a function when the transition is triggered.
If upLevelsForExternalTransition
is supplied, the developer must ensure that the either the source or the target
is the ancestor of the other. We cannot verify this at the moment this method is called because the target state may not
exist yet (it may only be referred to as its id).
src:State — Source state pointer.
| |
tid:String — Target state identifier.
| |
tfn:Function (default = null ) — Transition function -- invoked if the Transition is fired.
| |
doHistory:Boolean (default = false ) — Boolean value indicating whether or not to go to the History pseudo-state of the target state.
| |
upLevelsForExternalTransition:uint (default = 0 ) — This is only for external transitions: it lets one control how many parent states upward the engine exits before returning to enter the state again.
|