Using Keyboard Events to Call Methods in Actionscript

function onKeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.ENTER:
box.play();
break;
case Keyboard.BACKSPACE:
box.stop();
break;
case Keyboard.LEFT:
box.prevFrame();
break;
case Keyboard.RIGHT:
box.nextFrame();
break;
case Keyboard.SPACE:
box.gotoAndStop(3);
break;
default:
trace(“keyCode:”, evt.keyCode);
}
};

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.