Keyboard / Mouse quirk....

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default Keyboard / Mouse quirk....

    I've defined a Key object and within its onPress action I set a variable userKeyUp to false. In the Key's onRelease action I set userKeyUp back to true. Similarly, I have a button object and in its onPress action I also set the variable userKeyUp to false, and in its onRelease action the variable is set to true. The idea is to prevent cross-talk between the keyboard and mouse in the interface (i.e. multiple things happening at once, multiple subsequent keypresses higher than framerate, etc). However, for some reason it isn't working as expected. (The button and key words below are replaced with actual object names in my code.)

    userKeyUp = true;

    button.onPress = function() {
    userKeyUp = false;
    nextFrame();
    } // flag key down and advance to next frame

    button.onRelease = function() {
    userKeyUp = true;
    } // flag key up when button is released

    key.onKeyDown = function() {
    if(userKeyUp) {
    button.gotoAndStop("_down");
    userKeyUp = false;
    nextFrame();
    } // perform actions only if key flag is true
    }

    key.onKeyUp = function() {
    userKeyUp = true;
    } // flag key up

    (The code above is stripped down and simplified so you can see the basic logic clearly.) With this code, supposedly, if I click and hold the mouse down on the button object, I should not be able to execute any keyboard actions in the keyonKeyDown function until the mouse has been released. However, what's really happening is the keyboard is working normally while the mouse is held down. Any ideas why this isn't working?


    Knight Miniatures webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Varible clearance, mouse/keyboard
      I seem to be having problems with my login scripts. I have mentioned this here before, but have some more ideas i would like to run past you all....
    2. Mouse click or keyboard...
      Hi people... this is an easy one... i want to add a script to my movie... that makes it go to the next frame when the users clicks the mouse...
    3. USB Keyboard & Mouse Compatability
      Hi, I have a USB wireless keyboard and mouse combo. When I start the set up programme for Mandrake 9.1 they are recognised until after I press...
    4. Trying to setup a wireless keyboard + mouse
      Hi everybody, I'm trying to setup a Debian (unstable) system running on a 2.4.21 kernel with a mouse + keyboard wireless (RF) combo. The model...
    5. Keyboard & Mouse Not Responding
      Thanks I will pass on the suggestion to my mom. I'm not sure what OS version she is using. It would be whatever version shipped with it 2 years...
  3. #2

    Default Re:Keyboard / Mouse quirk....

    By the way, I've also tried this using two flags, one for the keyboard and one for the mouse, so that keyboard key releases won't reset the userKeyUp flag while the mouse is still down. In the onKeyDown function, I then used if(userKeyUp && mButtonUp) but the same results are happening. Keyboard keys are still performing the nextFrame action while the mouse is down, despite the variables being true (confirmed with a trace action).


    Knight Miniatures webforumsuser@macromedia.com Guest

  4. #3

    Default Re:Keyboard / Mouse quirk....

    More info:

    This IS working fine when the movie plays as a _root. However, if the movie is placed inside another movie, as I am doing, then it suddenly stops working. Still have no clue why....


    Knight Miniatures webforumsuser@macromedia.com Guest

  5. #4

    Default Re:Keyboard / Mouse quirk....

    Okay, this is scary....After exiting out of Flash and restarting it, the mouse and keyboard actions are behaving correctly, even inside nested movie clips. So now that it's working, the question becomes how reliable is this?


    Knight Miniatures webforumsuser@macromedia.com Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139