A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: keyDown to frame question

  1. #1
    Member
    Join Date
    Jun 2001
    Location
    Northern Hemisphere
    Posts
    61

    keyDown to frame question

    I have code that, when pressing the left or right key, will go to the next frame within my movie:
    Code:

    Code:
    stop();
    
    this.onKeyDown = function() {
        if (Key.getCode() == Key.LEFT) {
            this.prevFrame();
        } else if (Key.getCode() == Key.RIGHT) {
            this.nextFrame();
        } 
    };
    Key.addListener(this);
    However, this will go to the next frame and stop.

    How can I get it so it will go to the next frame and play through the time line until I put in a stop command?
    Or, along the same lines, how could I set it so on keyDown it will go to and play whatever frame I choose?

  2. #2
    Member
    Join Date
    Jun 2001
    Location
    Northern Hemisphere
    Posts
    61
    Never mind.
    Here's the answer:

    Code:
    this.onKeyDown = function() {
    	if (Key.getCode() == Key.LEFT) {
    		this.gotoAndPlay(1);
    	} else if (Key.getCode() == Key.RIGHT) {
    		this.gotoAndPlay(2);
    	} 
    };
    Key.addListener(this);
    It's been a LLLOOONNNGGG week.

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