Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Author Topic: How can I trace the Transition Action called during a state machine transition?  (Read 7698 times)
Posts: 5

View Profile Email
« on: August 08, 2009, 07:42:24 »

Take the following state machine code example
<state name={STATE_ONE}
<transition action={ACTION_FOO} target={STATE_TWO}/>

<state name={STATE_TWO}
<transition action={ACTION_BAR} target={STATE_TWO}/>

How can I trace specifically which transition action caused the state transition?

In other, words how can find out if it was ACTION_FOO or ACTION_BAR that caused a transition to STATE_TWO?

Another way of putting it. Assume ENTER_STATE_TWO is mapped to the following command:

package com.app.controller
import com.app.ApplicationFacade;

import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;

public class EnteringStateTwoCommand extends SimpleCommand
override public function execute(note:INotification):void
                    // Entering guard code goes here

Assume somewhere in my code there are the following notifications sent:
sendNotification(StateMachine.ACTION, null, ACTION_FOO);


sendNotification(StateMachine.ACTION, null, ACTION_BAR);

How can I query which specific ACTION brought me to this state when I am in the EnteringStateTwoCommand command? Or anywhere else in the state machine event chain for that matter. Theoretically it could be either ACTION_FOO or ACTION_BAR in the above command.

Maybe I overlooked something but what is the syntax to get the actual value of the transition action itself during a state machine notification? Is it

Maybe it isn't possible to get the ACTION in this command? Where and when can I find out about the transition action? I am trying to debug the logic flow in my app's state machine implementation.
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: August 09, 2009, 07:47:58 »

States should be decoupled; unaware of each other. Where you came from should not be of any consequence when you have entered a new State. 

You can pass data from State to State in the note body, but you will not be advised of what the ACTION was in the state-specific changed notification that is fired when you reach a new State.

For troubleshooting, I would suggest using the Flex Builder debugger to step through your code instead of mucking about with trace statements. Just set a breakpoint on the lines that send the ACTION notes and then step through the code manually when the debugger hits the breakpoint.

Pages: [1]