1 Reply Latest reply on Jul 29, 2006 8:15 AM by mr-m

    Key press and won't stop

    mr-m Level 1
      I am writing a game where I want to use the key board to fire missiles. When the f key is pressed it keeps firing missiles until another key is pressed. Does the listener store the value of 70 for the f key and keeps thinking the key is being pressed. I tried to only use the listener without putting the function in the onEnterFrame but nothing would happen when I pressed f.

      here is the code I am using.

      var myListener = new Object();
      myListener.onKeyDown = onMyKeyDown;
      Key.addListener( myListener );

      _root.onEnterFrame = function() {
      myOnKeyDown() //does not fire without this here.

      function myOnKeyDown() {
      if (Key.getCode() == 70 && drop == "yes") {
      drop = "no";

      function missileFire() {
      //if (Key.isDown(key.PGUP)) { <<it worked with this when I didn't use the f key to fire.
      if (bombs > 0) {
      //if (drop == "yes") {

      } //enterframe
      }//if bombs greater than zero
      }//closes bomb function