[FMX] Need help with Key Pressing!

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…

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…

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 :slight_smile:

I see, thanks.

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

Man… The tapping doesn’t work… :frowning:
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?

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:

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?

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:-\

Humph! Maybe the problem is with my comp or keyboard… :-
Oh well thanks anyway :smirk: .

works on my comp ok…