Transition between States in PureMVC StateMachine Utility

Below you can see what’s happening when transition between states occurs. First your application sends a StateMachine.ACTION Notification that triggers the StateMachine to begin a transition. Any state specific exiting or entering guard(Commands or Mediators) defined for the current and target state are notified. If transition is not cancelled the current state is changed to the target state and any state specific CHANGED annoucement is sent. And finally a generic annoucement of the CHANGED is sent.


Useful Resources:
Get your FSM on!
StateMachine Utility overview presentation by Cliff Hall
Lockable Door demo

3 Comments


  1. Larry
    July 27, 2009 at 2:43 pm

    Thanks for this post. I am so confused by the State Machine as to its use. Does this manage states in the Flex app as in the different visual states? What needs to be done to get this set up? Most of the stuff i have read takes for granted that the person knows how to set this up. I may just be a little slow… but more detail would be great! Thanks for your time.

  2. Larry
    July 27, 2009 at 2:46 pm

    I’m sorry… you do have examples… I will check them out… Thanks.

  3. Mariush T.
    July 28, 2009 at 2:21 pm

    The StateMachine is different than the Flex View States. The Flex View States manages states of view components where the StateMachine manages states of your application(not just a view). http://puremvc.tv/#P003/T315

    Look at the PureMVC StateMachine lockable door demo. For simplicity’s sake LockableDoor demo manages only visible states of application. You can find more advanced example of FSM in StateMachine overview presentation by Cliff Hall. http://puremvc.tv/#P003/T365

    Step by Step FSM Setup:
    You need to download StateMachine Utility. http://trac.puremvc.org/Utility_AS3_StateMachine
    Select which version you want to use:singlecore or multicore.
    Add .swc to your project library.
    Create FiniteStateMachine XML in InjectFSMCommand.
    Add InjectFSMCommand into StartupCommand.

    Application->StateMachine
    To communicate with StateMachine from application send StateMachine.ACTION notification – sendNotification(StateMachine.ACTION, null, event.type), example ApplicationMediator.
    NOTE: Only Mediators and Commands should send StateMachine.ACTION, not Proxies.

    StateMachine->Application
    StateMachine communicates with the application completely via notifications. You can listen for notifications in two ways: register commands with specific notification, example ApplicationFacade or listen for notifications within mediators.

    View full source code for LockableDoor demo

    Good luck!

Leave a comment