A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Button sensitivity

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Posts
    412

    Button sensitivity

    Is there a way I can make Flash realize that the spacebar button should only be hit once? I have a problem where the keyboard is too sensitive, and sometimes Flash is reading it as if I pressed it twice, thus excuting a second command. Is there a way around this?

    Here's the situation:
    A character is walking, it collides with another character, which gives the user a prompt to talk to the other character. Now, if the user hits spacebar, the dialog screen will appear. In this dialog screen, I want to have a default response already chosen, so that the user can just hit spacebar to choose that response. The problem is, if the keyboard is too sensitive, the first time the visitor hits spacebar, it goes straight to the second dialog screen because Flash took the second spacebar hit to indicate to move on. How can I solve this problem?

  2. #2
    Senior Member
    Join Date
    Oct 2000
    Posts
    412
    Anyone?

  3. #3
    Member
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    31
    Hi,

    You can use a 'timer' to calculate the time between the first hit and the second! If the time difference between both hits is to close, it's not registered as a second hit...

    Look at this tutorial! It explains how you can manage that...
    http://www.flashkit.com/tutorials/In...-666/index.php
    WEBDESIGN is ART, or it is not WEBDESIGN
    ----------------------------------------
    email: mail@thelegend.be
    website: www.thelegend.be

  4. #4
    Deathbringer sylkro's Avatar
    Join Date
    Oct 2000
    Location
    London
    Posts
    202
    is the chat function initated onKeyUp or with an Key.isDown(32)?

  5. #5
    Senior Member
    Join Date
    Oct 2000
    Posts
    412
    is the chat function initated onKeyUp or with an Key.isDown(32)?
    It's using Key.isDown(SPACE)

  6. #6
    Deathbringer sylkro's Avatar
    Join Date
    Oct 2000
    Location
    London
    Posts
    202
    then use onKeyUp. isDown is best suited for instant, repetitive actions... like a character walking, and works better than onKeyDown. onKeyUp, happens when the key is released, or once every down/up cycle so it will not be affected by the sensitivity.

    that said, if you can't alter your code, just set a variable to say your character is chatting:

    if (Key.isDown(SPACE) and !chatting) {
    chatting = true;
    beginChatting();
    }

    when they're finished:

    chatting = false;


    make sure you set chatting to false before. relying on undefined isn't safe if you come back to the frame cos it could be still set to true.

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