A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Key Press Controls

  1. #1
    Junior Member
    Join Date
    Nov 2002
    Posts
    21

    Key Press Controls

    Ok...I have scripted the left and right keyboard buttons to play a walking animation for my game character in the obvious directions.
    The problem is - when the keys are released I want to goto a different frame (still animation). Seeing as how there is no "On key release" event, how could I accomplish this?

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    2,545

    Hello SmokeRingHalo

    The attached file may or may not answer your question.

    I hope it helps,

    ~Jer~
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Nov 2002
    Posts
    21
    I already knew how to move the sprite with key controls but thats not what I want to do. It will stay in place while the background will scroll accordingly. Instead I need it to go to certain frames for a walking animation while the key is pressed and return to it's initial frame when its not.
    Example: Frame 1 is a standing still animation

    //Frame 3 walking right animation
    on (keyPress("<Right>")) {
    tellTarget (player) {
    gotoAndPlay(3);
    }
    }
    //Frame 5 walking left animation
    on (keyPress("<Left>")) {
    tellTarget (player) {
    gotoAndPlay(5);
    }
    }
    I need it it to return to frame 1 when the key is not being pressed.
    So since there isn't a event of this nature, I'm thinking it may have to be conditional, but I'm not exactly sure.
    Any suggestions?

  4. #4
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797
    Think background as another sprite.

  5. #5
    Junior Member
    Join Date
    Nov 2002
    Posts
    21
    I don't think you understand what I'm trying to say as the background is another sprite.
    I will simplfy the problem.
    When I press a key I want an animatiuon to start and when I release the key I want the animation to stop. Not the mouse buttons - the keyboard. How can I do this?

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