PDA

View Full Version : [FMX] Need help with Key Pressing!!



__FLATLINE__
October 26th, 2002, 12:14 PM
Ok so I have this tapping game where I need to quickly tap a key, but I don't know how to do it in Flash... All I know is on(KeyPress) but that allows me to simply hold down the key...

It'll be great if anyone can post how to increase a scale of something (lets say a bar) every time spacebar is pressed or released, but having to tap spacebar instead of holding it...

Scootman
October 26th, 2002, 11:04 PM
uhh try just puttin a button off the side of your stage so people wont see it... and then put on(release"<key>") so every time they let the key up it will do it... i think... not sure if thats the right syntax but try release instead of press...

pom
October 27th, 2002, 03:29 AM
If your bar is called bar then you can try this.
bar.onKeyDown=function(){
if (Key.isDown(Key.SPACE)&&!this.p){
bar._xscale+=5;
this.p++;
}
}
bar.onKeyUp=function(){
this.p=0;
}
Key.addListener(bar);It's not very elegant but it does the job.

pom :)

__FLATLINE__
October 27th, 2002, 08:54 AM
I see, thanks.

But tell me, what does this line do?
Key.addListener(bar);

__FLATLINE__
October 27th, 2002, 09:13 AM
Man... The tapping doesn't work... :-(
It doesn't work well when I tap the spacebar quickly, only when I do it rather slow... But I want to force the player to tap the spacebar FAST...

Also, where exactly am I supposed to put this code anyway?

pom
October 27th, 2002, 02:25 PM
It works for me. You have to put the code in a frame of a timeline containing a clip called bar.

I made a sample movie. The bar is very thin in the middle of the movie.

Cheers.
pom :cowboy:

__FLATLINE__
October 27th, 2002, 04:36 PM
That's sorta what I did but that's not what I meant in the problem.

The problem is that the player has to steadily and even slowly tap the spacebar, but my goal is to make the player to tap the spacebar as fast as possible.

Is there a way to make it work like this?

pom
October 28th, 2002, 07:58 AM
As I said, the movie works for me whether you press fast or not so fast... I don't really understand what the problem is:-\

__FLATLINE__
October 28th, 2002, 12:55 PM
Humph! Maybe the problem is with my comp or keyboard... :-\
Oh well thanks anyway :smirk: .

Scootman
October 28th, 2002, 11:50 PM
works on my comp ok...