Skip to main content
Known Participant
July 29, 2009
Question

Keyboard Events

  • July 29, 2009
  • 1 reply
  • 1922 views

my keyboard functions are working fine, except after i jump to a frame and then use the back arrow key it only goes back through the even frames and then the odd frames. Any ideas on how to fix this?

stop();
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
function onKeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.ENTER:
if(this.currentFrame == 5){
     gotoAndStop(10);
} else {
     gotoAndStop(5);
}

//gotoAndStop(5);
break;


case Keyboard.RIGHT:
nextFrame();
break;


case Keyboard.LEFT:
prevFrame();
break; }

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 29, 2009

your code looks ok.  if you see jumps of two frames it usually means you have another kb listener defined.

PladflagAuthor
Known Participant
August 6, 2009

is there anyway to have multiple  keyboard listeners?

kglad
Community Expert
Community Expert
August 6, 2009

sure.  just define two listener function and two listeners.  and there are other scenarios where you can have 2 keyboard listeners.