statemachine-as3 is lightweight state machine based on closures. The library comes with two state machine flavours: StateMachine (where transitions are triggered directly) and EventStateMachine (where transitions are triggered by Event and EventDispatcher).
Sample
//StateMachine
var sm : StateMachine = new StateMachine("process.step1");
//EventStateMachine
var esm : EventStateMachine = new EventStateMachine("process.step1");
//StateMachine
sm.add(
//From state...
"process.step1",
//To state...
"process.step2",
//Action-Filter which is triggered on transition
function() : Boolean {
//If true is not returned, the transition will not complete
return true;
}
);
//EventStateMachine
esm.add(
//From state...
"process.step1",
//To state...
"process.step2",
//When the following flash.events.EventDispatcher...
processDispatcher,
//Dispatches the flash.events.Event...
Step2Event,
//Action-Filter which is triggered on transition
function( ... Arguments ) : Boolean {
//Arguments are received from the EventDispatcher
for each( var argument : * in Arguments ) {
//...
}
//If true is not returned, the transition will not complete
return true;
}
);
//StateMachine
sm.state = "process.step2";
//EventStateMachine
processDispatcher.dispatch(Step2Event);
//StateMachine
trace(sm.state);
//EventStateMachine
trace(esm.state);






RT @as3gamegears http://t.co/syivytT0 #as3 #flash #gamedev: New: statemachine-as3 (lightweight state machine ba… http://t.co/ZWLp0sFN