var machine = new MyStateMachine( { //state "ready": { //event name: new state "mouse-move": "ready", "mouse-down": "dragging" }, "dragging": { "mouse-move": "dragging", "mouse-up": "ready" } }, "ready", handleStateChange);