Code:
/*Create the Listener that waits for keyboard Input, then tell it what function to call when a key is pressed down*/ stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDownHandler); stage.focus=stage; //What happens when a key is pressed! function KeyDownHandler(keyEvent:KeyboardEvent) { /*Convenient Switch statement allows for quicker key presses. All you need is to use the correct Key Code!*/ switch(keyEvent.keyCode) { case 37 :// Left Arrow was Pressed myGraphic.rotation += 5; break; case 39 :// Right Arrow was Pressed myGraphic.rotation -= 5; break; } }
Leave a comment: