Here we go!
Each function will be triggered after each keyboard mash, rather than key press:
Hope that's what you want!Code:var myFunctions:Array = [firstFunc, secondFunc, thirdFunc]; var fPointer:int = 0; var keysPressed:Array = new Array(); stage.addEventListener(KeyboardEvent.KEY_DOWN, collectKey); stage.addEventListener(KeyboardEvent.KEY_UP, listenForMash); function collectKey(e:KeyboardEvent):void { if(keysPressed.indexOf(e.keyCode) == -1) { keysPressed.push(e.keyCode); } } function listenForMash(e:KeyboardEvent):void { var io:int; if((io = keysPressed.indexOf(e.keyCode)) != -1) { keysPressed.splice(io, 1); } if(keysPressed.length == 0) { myFunctions[fPointer++](); // call the next function; if(fPointer == myFunctions.length) { fPointer = 0; // loop back to the beinging; } } } function firstFunc():void { trace("firstFunc() called!"); } function secondFunc():void { trace("secondFunc() called!"); } function thirdFunc():void { trace("thirdFunc() called!"); }




Reply With Quote