4 Replies Latest reply on Jun 3, 2006 2:29 PM by IndianChsPrdctns

    Substitute from spacebar to mouse

    IndianChsPrdctns
      I have 2 snippets of code for a game. In the code, the spacebar key is defined as "jump". I want to use a left mouse click instead of the space bar to perform the action, however. The code snippets are quite lengthy, but I have no other choice. Here is the first code:


      if (Key.isDown(jump) && g == "on" && tunnel != "on")
      {
      if (jumpdown == "off")
      {
      if (duck == "on")
      {
      _root.fx.fx("dash");
      dash = "on";
      }
      else
      {
      _root.fx.fx("jump");
      makejump();
      } // end if
      } // end else if
      jumpdown = "on";
      }
      else
      {
      jumpdown = "off";
      } // end else if
      if (duck != "on" && dash == "on")
      {
      _root.fx.fx("dashoff");
      x = _xscale / 100 * 15;
      roll = "on";
      dash = "off";
      } // end if
      if (roll == "on" && x <= 2 && x >= -2)
      {
      roll = "off";
      } // end if
      tunnel = "off";
      } // End of the function


      And now the second:


      if (Key.isDown(jump))
      {
      if (jumpdown == "off")
      {
      if (chara == "tails" || chara == "cream")
      {
      if (fly == "off")
      {
      if (j == "on")
      {
      fly = 100;
      j = "off";
      } // end if
      }
      else if (fly > 0)
      {
      if (y < 2)
      {
      y = y + 1;
      }
      else
      {
      y = 2;
      } // end if
      } // end if
      } // end else if
      } // end else if
      jumpdown = "on";
      }
      else
      {
      jumpdown = "off";
      } // end else if
      } // End of the function


      You can probably tell which kind of game I am making from the code.