A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Problems with gotoAndPlay

  1. #1
    Junior Member
    Join Date
    Jul 2010

    Angry Problems with gotoAndPlay

    I have written Actionscript 3 to listen for keyboard events. For instance, if the user is on frame 2 of the timeline, and they press the right arrow key on the keyboard, they will gotoAndPlay (3). This works fine.

    I have also programmed the left arrow key to go back frames. For instance, if they are on frame 2, and they press the left arrow, it will gotoAndPlay (1). This works OK, but here is the problem.

    Once they go back to frame 1, if they press the right arrow key, it should go to frame 2. But, it doesn't. It picks up from frame 2 and jumps to frame 3.


  2. #2
    Senior Member
    Join Date
    Jul 2008
    Where did you put your code? Is it a separate listener on each of the 3 frames or just one listener that spans the 3 frames? Although it doesn't really matter for what I'm suggesting...

    Try this
    PHP Code:
    stage.addEventListener (KeyboardEvent.KEY_DOWNonStageKeyDownfalse0true);
    onStageKeyDown (e:KeyboardEvent) {
        if (
    e.keyCode == Keyboard.LEFT) {
    this.prevFrame ();
        } else if (
    e.keyCode == Keyborad.RIGHT) {
    this.nextFrame ();

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Have you tried gotoAndStop or nextFrame and prevFrame?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center