Two Things

Well, I actually have two things. First, I have an easy method for a jumping system in a flash game. It’s a bit glitchy, but here it is:


onClipEvent(load) {
       var fallness = 10; } 
onClipEvent(enterFrame){           
       if (!this.hitTest(_root.ground) && !Key.isDown(Key.UP)) {  
             this._y += fallness; 
        } 
         if (Key.isDown(Key.UP)) {
	gravity -= 1;
	this._y -= gravity;
        }
        if (this.hitTest(_root.ground)) {
	gravity = 10; 
          } 
} 
onClipEvent (keyUp) {
       gravity = 10;
}

ok so there you can apply your own crap to it. And I have another thing to ask: how would you go by using a switch statement. ive been having trouble with them along with for… in loops

Sorry for double posting, but this thread has been up for a while, so could someone please reply. Thank-You for your help.

I’m not sure what your first question is, but you can find some information about the second here: http://www.kirupa.com/developer/actionscript/as_tricks.htm

pom :slight_smile:

Same here with the first question but with the second you could use something like:

myVar = Key.getCode();

Then use myVar in a switch statement:

[AS]
switch(myVar) {
case (37):
do some stuff;
break;
case (39):
do some other stuff;
break;
default:
do some default stuff;
break;
}
[/AS]

You can look up the numbers in the Flash reference for the key codes. Also check out Best of Senocular for excellent explanation of switch/case by clicking

here :thumb: