StateMachine Setup Error

kyle's Avatar


27 Oct, 2009 09:54 AM

Hi Guys,

[Hope i'm placing this in the correct place!]

I used the StateMachine all the time in PureMVC and was stoked to see it used in RobotLegs.
But on my first attept to implement it i have run into an error, which could quite likely be something im doing incorrectly.

    override public function execute():void
        var fsm:XML = 
        <fsm initial={LoadupEvent.STATE}>
            <state name={LoadupEvent.STATE} entering={LoadupEvent.ENTER} exiting={LoadupEvent.EXIT} changed={LoadupEvent.CHANGED} />

        var stateMachine:StateMachine = new StateMachine();
        var fsmInjector:FSMInjector = new FSMInjector(fsm);


This is throwing the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at org.swiftsuspenders::VariableInjectionPoint/applyInjection()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/]
    at org.swiftsuspenders::Injector/injectInto()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/]
    at com.freeworldcoatings.intranet.controller.controls.prep::PrepStateMachineCommand/execute()[C:\dev\Freeworld Intranet\site\src\com\freeworldcoatings\intranet\controller\controls\prep\]
    at org.robotlegs.base::CommandMap/routeEventToCommand()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/]
    at <anonymous>()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/]
    at com.freeworldcoatings.intranet::ApplicationContext/startup()[C:\dev\Freeworld Intranet\site\src\com\freeworldcoatings\intranet\]
    at org.robotlegs.base::ContextBase/initialize()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/]
    at org.robotlegs.base::ContextBase()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/]
    at org.robotlegs.mvcs::Context()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/mvcs/]
    at com.freeworldcoatings.intranet::ApplicationContext()[C:\dev\Freeworld Intranet\site\src\com\freeworldcoatings\intranet\]
    at Main/init()[C:\dev\Freeworld Intranet\site\src\]
    at flash.display::DisplayObjectContainer/addChild()
    at Preloader/startup()[C:\dev\Freeworld Intranet\site\src\]
    at Preloader/checkFrame()[C:\dev\Freeworld Intranet\site\src\]

Any ideas? ......... also i have just moved from using the "Proxy' version of RL to the 9.5 release.


  1. Support Staff 1 Posted by Joel Hooks on 27 Oct, 2009 02:22 PM

    Joel Hooks's Avatar

    I'd need to see more code, but I didn't test the FSM against a single state. I will add that to the unit tests and see if I can reproduce the error. I also didn't test against the entering position, so I will do that also. Thank you for providing some cases ;)

    This is what I'd consider the minimal setup for the state machine (as it is now):

        <pre>private var fsm:XML =
            <fsm initial={STARTING}>
                <!-- THE INITIAL STATE -->
                <state name={STARTING}>
                   <transition action={STARTED} 
                   <transition action={START_FAILED} 
                <!-- DOING SOME WORK -->
                <state name={CONSTRUCTING} changed={CONSTRUCT} exiting={CONSTRUCTION_EXIT}>
                   <transition action={CONSTRUCTED} 
                   <transition action={CONSTRUCTION_FAILED} 
                <state name={NAVIGATING} changed={NAVIGATE}/>
                <!-- REPORT FAILURE FROM ANY STATE -->
                <state name={FAILING} changed={FAIL}/>
  2. 2 Posted by kyle on 27 Oct, 2009 02:37 PM

    kyle's Avatar

    This is the project so far, i only have two states.

  3. Support Staff 3 Posted by Joel Hooks on 27 Oct, 2009 03:38 PM

    Joel Hooks's Avatar

    LoadupMonitorEvent is missing from the archive, and there is an error
    in at line 50 calling a class, loginMC().

    I think also that using event constants for the state constants is
    probably a bad idea, as the state machine is utilizing the central
    event bus. This could very well introduce conflicts. Better to just
    have a static StateMachineConstants class that defines these states:

    here is an example of that.

  4. Support Staff 4 Posted by Joel Hooks on 27 Oct, 2009 04:34 PM

    Joel Hooks's Avatar

    Hey Kyle,

    I gutted out some stuff just to show the FSM in your app as it cycles through some states. I've attached the src folder.

  5. 5 Posted by kyle on 28 Oct, 2009 06:56 AM

    kyle's Avatar

    Hi Joel,

    Thanks for the feedback and help.
    I like the StateMachineConstants idea and will now implement it!

    In your refleshing you code:

            var stateMachine:StateMachine = new StateMachine(eventDispatcher);

    But in the versions of statemachine i have, from git, the statemachine doesnt take a constructor parameter. Presumable i have the wrong version?


  6. Joel Hooks closed this discussion on 29 Oct, 2009 06:46 AM.

  7. Joel Hooks re-opened this discussion on 29 Oct, 2009 06:47 AM

  8. Support Staff 6 Posted by Joel Hooks on 29 Oct, 2009 06:47 AM

    Joel Hooks's Avatar

    I emailed a reply, I guess it didn't go through, but yes, that was an older version.

  9. Joel Hooks closed this discussion on 29 Oct, 2009 11:35 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac