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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / FSM Uses & Limitations / Async transitions on: March 31, 2009, 05:16:34
I've been reading a few discussions on the forums regarding the state machine utility, and have left possibly more confused than when I started:


I see how FSM provides nice exiting/entering/changed notifications, but it looks like they're synchronous - in real life that sequence would happen nearly instantaneously, correct?  From StateMachine.as -> transitionTo:

:
// Exit the current State
if ( currentState && currentState.exiting ) sendNotification( currentState.exiting, data, nextState.name );

// Check to see whether the transition has been canceled
if ( canceled ) {
canceled = false;
return;
}

// Enter the next State
if ( nextState.entering ) sendNotification( nextState.entering, data );
currentState = nextState;

// Send the notification configured to be sent when this specific state becomes current
if ( nextState.changed ) sendNotification( currentState.changed, data );

// Notify the app generally that the state changed and what the new state is
sendNotification( CHANGED, currentState, currentState.name );


In my app, I need to handle transitions visually by tweening properties over time.  This means exiting the current state could take 1.2 seconds, entering the next state takes 1.5 seconds, and maybe I want them to overlap by 0.4 seconds.  And maybe I want "changed" to fire .2 seconds before the entering transition is done. Possible with FSM or not?

thanks.
2  Announcements and General Discussion / General Discussion / StateMachine - crossing many states on: March 06, 2009, 02:43:55
Hi,

I'm attempting to use StateMachine for the first time and have a question about states and transitions.  In the open/close/lock door example I see how it's possible to limit which states are available from the current state.  However, in my app, using SWFAddress a user could conceivably go TO any state FROM any state by typing in a direct URL, BUT, it might be necessary to travel through multiple states to get there.

For simplicity sake, lets use an example of an app that moves a box to the 4 corners of your screen, each corner represented by a state.  Changing state tweens the box to the correct position, but it only moves horizontally and vertically, in a clockwise fashion.  States:

:
<fsm initial="TOP_LEFT">

<state name="TOP_LEFT">
<transition action="TO_TOP_RIGHT" target="TOP_RIGHT" />
</state>

<state name="TOP_RIGHT">
<transition action="TO_BOTTOM_RIGHT" target="BOTTOM_RIGHT" >
</state>

<state name="BOTTOM_RIGHT">
<transition action="TO_BOTTOM_LEFT" target="BOTTOM_LEFT" >
</state>

<state name="BOTTOM_LEFT">
<transition action="TO_TOP_LEFT" target="TOP_LEFT" />
</state>

</fsm>



So the site inits the box at TOP_LEFT and the user types in http://sweetboxapp.com/#/bottomright.  The box needs to move from TOP_LEFT to TOP_RIGHT, then from TOP_RIGHT to BOTTOM_RIGHT, essentially moving through states.  While this example is simple, in the app I'm developing a user could move through a maximum of 6 states.  It's important (or at least I think it is) to maintain the idea of moving through states because of the transitions that are required.  ie. TOP_LEFT can't go to BOTTOM_RIGHT directly, it must move through TOP_RIGHT.

Am I thinking about this correctly?

thanks,
Trevor

Pages: [1]