# Two Things

**URL:** <https://forum.kirupa.com/t/two-things/38794>\
**Category:** flash\
**Created:** [December 29, 2003, 11:07pm UTC](https://forum.kirupa.com/t/two-things/38794 "2003-12-29T23:07:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![InsaneMonk](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@InsaneMonk](https://forum.kirupa.com/u/InsaneMonk)\
**Post date:** [December 29, 2003, 11:07pm UTC](https://forum.kirupa.com/t/two-things/38794/1 "2003-12-29T23:07:08Z")

</div>

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:

```auto

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 5:28pm UTC](https://forum.kirupa.com/t/two-things/38794/2 "2003-12-30T17:28:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 5:51pm UTC](https://forum.kirupa.com/t/two-things/38794/3 "2003-12-30T17:51:01Z")

</div>

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](http://www.kirupa.com/developer/actionscript/as_tricks.htm)

pom 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 5:59pm UTC](https://forum.kirupa.com/t/two-things/38794/4 "2003-12-30T17:59:38Z")

</div>

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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15407) :thumb:
