# Space Realese

**URL:** <https://forum.kirupa.com/t/space-realese/16283>\
**Category:** flash\
**Created:** [March 23, 2003, 3:20am UTC](https://forum.kirupa.com/t/space-realese/16283 "2003-03-23T03:20:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![BullDog\_Flash](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@BullDog\_Flash](https://forum.kirupa.com/u/BullDog_Flash)\
**Post date:** [March 23, 2003, 3:20am UTC](https://forum.kirupa.com/t/space-realese/16283/1 "2003-03-23T03:20:34Z")

</div>

Well see i am making a new game(Took forever)

But see i noticed i can hold in Space bar and the counter will keep going up here si the code.

```php
onClipEvent (enterFrame) {
    if (Key.isDown(Key.SPACE)) {
        _root.pu += 1;
    }
}

```

But i wouold want it to only go up when the SPACE bar is realesed

But how(Stumpued just like him:chinaman: )  
Plesase 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:** [March 23, 2003, 3:31am UTC](https://forum.kirupa.com/t/space-realese/16283/2 "2003-03-23T03:31:32Z")

</div>

quick test …

```auto
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)) {
ok = true;
} else {
if (ok) k++;
ok = false;
}
trace(k);
}

```

like that?

---

<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:** [March 23, 2003, 4:14am UTC](https://forum.kirupa.com/t/space-realese/16283/3 "2003-03-23T04:14:17Z")

</div>

or a shorter method

```auto

onClipEvent(enterFrame){
	if (s-(s=Key.isDown(Key.SPACE))>0) _root.pu++;
}

```

sorry kax, couldnt resist 😉

---

<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:** [March 23, 2003, 4:16am UTC](https://forum.kirupa.com/t/space-realese/16283/4 "2003-03-23T04:16:05Z")

</div>

> _Originally posted by senocular_  
> **sorry kax, couldn’t resist 😉**

it’s ok =). i love being belittled by you 😉 😛

---

<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:** [March 23, 2003, 4:21am UTC](https://forum.kirupa.com/t/space-realese/16283/5 "2003-03-23T04:21:07Z")

</div>

onClipEvent(enterFrame){  
if (s-(s=Key.isDown(Key.SPACE))\>0) \_root.pu++;  
}

I will test these both

onClipEvent (enterFrame) {  
if (Key.isDown(Key.SPACE)) {  
ok = true;  
} else {  
if (ok) k++;  
ok = false;  
}  
trace(k);  
}

---

<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:** [March 23, 2003, 4:26am UTC](https://forum.kirupa.com/t/space-realese/16283/6 "2003-03-23T04:26:13Z")

</div>

> \*Originally posted by senocular \*

```auto

onClipEvent(enterFrame){
	if (s-(s=Key.isDown(Key.SPACE))>0) _root.pu++;
}

```

that’s an interesting bit… do you mind explaining it?.. i just cant get it :beam:

---

<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:** [March 23, 2003, 4:27am UTC](https://forum.kirupa.com/t/space-realese/16283/7 "2003-03-23T04:27:35Z")

</div>

Sorry Kax but i like senocular  
better he is my best frined.

I also killled his cat

---

<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:** [March 23, 2003, 4:30am UTC](https://forum.kirupa.com/t/space-realese/16283/8 "2003-03-23T04:30:41Z")

</div>

> _Originally posted by Bulldog\_Flash_  
> \*\*Sorry Kax but i like senocular  
> better he is my best friend.

I also killled his cat\*\*

i don’t care … he’s gonna marry me :beam: 😛

---

<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:** [March 23, 2003, 4:35am UTC](https://forum.kirupa.com/t/space-realese/16283/9 "2003-03-23T04:35:44Z")

</div>

> \*Originally posted by ahmed \*  
> \*\*that’s an interesting bit… do you mind explaining it?.. i just cant get it :beam: \*\*

😉

s is the variable the Key.isDown(Key.SPACE) is saved to, this happens every frame 🙂 Obviously. This happens in the if statement… again, fairly apparent. When it happens is after the first “s-” so if Key.isDown(Key.SPACE) is not the same at that point in time, that s in hte “s-” still holds the value of the previous frame - this value being either true or false, which numerically is either 1 (true) or 0 (false). And since the first s is not the current s, we are subtracting the values of Key.isDown(Key.SPACE) for this frame and the previous frame where it was last set: Last frame Space is down minus current frame space is down. Since we want to know when the space bar is released, we want the previous frame to be true and the current frame to be false or true minus false. That is the same as 1-0 which is 1 which is greater than 0. If both are true, you get 1-1 which is 0 and not \>0. Both false, 0-0, or 0 and not \>0. And with 0-1 you get -1 which is also, not \>0 (-1 is in the case of just pressing the space bar). So in the end the only thing greater than 0 is the releasing of space. You could also say ==1, but the \> sign is one character and == is 2 SAVED TYPING! 😉

:beam:

---

<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:** [March 23, 2003, 4:42am UTC](https://forum.kirupa.com/t/space-realese/16283/10 "2003-03-23T04:42:20Z")

</div>

:beam:  
i get it now, interesting… =)

---

<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:** [March 23, 2003, 3:23pm UTC](https://forum.kirupa.com/t/space-realese/16283/11 "2003-03-23T15:23:21Z")

</div>

Kax neve he wil never marry you.

::Goes on his bed and starts to cry::

---

<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:** [March 23, 2003, 3:37pm UTC](https://forum.kirupa.com/t/space-realese/16283/12 "2003-03-23T15:37:50Z")

</div>

:-\

for the sake of the anti **spam** wave [size=1]which i totally agree with[/size] … we should just leave this subject 😉 =)

anyway… we both know that he’s gonna marry me 😛

---

<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:** [March 23, 2003, 3:40pm UTC](https://forum.kirupa.com/t/space-realese/16283/13 "2003-03-23T15:40:14Z")

</div>

Yeah i think we should.  
Bas tard.

But yeah since sen explined his why dont you explain your please.
