Elan,
You mentioned you're using the following code:
Code:
if (Key.isDown(Key.SPACE) && jumpcounter<=2) {
grav = maxJump;
jumpcounter += 1;
}
Is that standalone or part of a larger function? In theory, that's correct. But, it has to be implemented properly. My guess is that you're adding that function within an onEnterFrame event or a function that's called in rapid succession.
A solution would be (as Schmoopy suggested) would be to use an event listener. Listen for the onKeyDown event, then test to see if the pressed key is the space bar. If it is, adjust your variables accordingly.
the KeyUp is for buttons.
onKeyUp() is an event. You can attach any function to it that you want. It doesn't need to be a button.
For example:
Code:
MovieClip.onKeyUp = function () {
trace ("You pressed a key");
};
You can use the Key.getAscii and Key.getCode methods to determine which key was pressed
Bookmarks