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: <i> 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 </i> And now the second: <i> 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 </i> You can probably tell which kind of game I am making from the code. ;)
I guess the easiest way is to use jump=1; However, if this code is going inside an onKeyDown event handler, it will not pick up the click. So, you would have to put this code in a loop (e.g. onEnterFrame)
An error like that is called a sintax error. This error does not mean that flash cannot do it. It means that you have forgotten to type something or that you wrote something that is not right. In the first snipped the last bracket does not have to be in there. If you want to use the mouse, well yes, there is actually a handler caller onMouseDown.
Don't see what you're looking for? Try a search.
|