Packageorg.puremvc.as3.multicore.utilities.statemachine
Classpublic class StateMachine
InheritanceStateMachine Inheritance org.puremvc.as3.multicore.patterns.mediator.Mediator

A Finite State Machine implimentation.

Handles regisistration and removal of state definitions, which include optional entry and exit commands for each state.



Protected Properties
 PropertyDefined by
  canceled : Boolean
The transition has been canceled.
StateMachine
  currentState : State
Get the current state.
StateMachine
  initial : State
The initial state of the FSM.
StateMachine
  states : Object
Map of States objects by name.
StateMachine
Public Methods
 MethodDefined by
  
Constructor.
StateMachine
  
handleNotification(note:INotification):void
Handle notifications the StateMachine is interested in.
StateMachine
  
Notification interests for the StateMachine.
StateMachine
  
onRegister():void
StateMachine
  
registerState(state:State, initial:Boolean = false):void
Registers the entry and exit commands for a given state.
StateMachine
  
removeState(stateName:String):void
Remove a state mapping.
StateMachine
Protected Methods
 MethodDefined by
  
transitionTo(nextState:State, data:Object = null):void
Transitions to the given state from the current state.
StateMachine
Public Constants
 ConstantDefined by
  ACTION : String
[static] Action Notification name.
StateMachine
  CANCEL : String
[static] Cancel Notification name
StateMachine
  CHANGED : String
[static] Changed Notification name
StateMachine
  NAME : String = "StateMachine"
[static]
StateMachine
Property detail
canceledproperty
protected var canceled:Boolean

The transition has been canceled.

currentStateproperty 
currentState:State  [read-write]

Get the current state.

Implementation
    protected function get currentState():State
    protected function set currentState(value:State):void
initialproperty 
protected var initial:State

The initial state of the FSM.

statesproperty 
protected var states:Object

Map of States objects by name.

Constructor detail
StateMachine()constructor
public function StateMachine()

Constructor.

Method detail
handleNotification()method
public override function handleNotification(note:INotification):void

Handle notifications the StateMachine is interested in.

StateMachine.ACTION: Triggers the transition to a new state.
StateMachine.CANCEL: Cancels the transition if sent in response to the exiting note for the current state.

Parameters
note:INotification
listNotificationInterests()method 
public override function listNotificationInterests():Array

Notification interests for the StateMachine.

Returns
Array
onRegister()method 
public override function onRegister():void
registerState()method 
public function registerState(state:State, initial:Boolean = false):void

Registers the entry and exit commands for a given state.

Parameters
state:State — the state to which to register the above commands
 
initial:Boolean (default = false) — boolean telling if this is the initial state of the system
removeState()method 
public function removeState(stateName:String):void

Remove a state mapping.

Removes the entry and exit commands for a given state as well as the state mapping itself.

Parameters
stateName:String
transitionTo()method 
protected function transitionTo(nextState:State, data:Object = null):void

Transitions to the given state from the current state.

Sends the exiting notification for the current state followed by the entering notification for the new state. Once finally transitioned to the new state, the changed notification for the new state is sent.

If a data parameter is provided, it is included as the body of all three state-specific transition notes.

Finally, when all the state-specific transition notes have been sent, a StateMachine.CHANGED note is sent, with the new State object as the body and the name of the new state in the type.

Parameters
nextState:State — the next State to transition to.
 
data:Object (default = null) — is the optional Object that was sent in the StateMachine.ACTION notification body
Constant detail
ACTIONconstant
public static const ACTION:String

Action Notification name.

CANCELconstant 
public static const CANCEL:String

Cancel Notification name

CHANGEDconstant 
public static const CHANGED:String

Changed Notification name

NAMEconstant 
public static const NAME:String = "StateMachine"