An Action Script 3 implementation of  finite-state machine (FSM).