Be a Supporter!

Frustrated !! Single Key Press

  • 240 Views
  • 6 Replies
New Topic Respond to this Topic
Lidve
Lidve
  • Member since: Dec. 21, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Frustrated !! Single Key Press 2009-10-16 16:18:53 Reply

A)#(#"HT#(Hiejigeiogwejigejiojigo4joig43 3g4j843g89g439j83g4j89g43j89g43j9ig4jio3 jig4o

huh

sry for that

is there ANY way to get simple "single key press" in flash

lets say user clicks and holds SPACE i just want that something happens once, not whole time he is holding space

JKR
JKR
  • Member since: Jan. 1, 2005
  • Offline.
Forum Stats
Member
Level 29
Animator
Response to Frustrated !! Single Key Press 2009-10-16 16:27:40 Reply

I'm SURE there's a better/earier way, but I'm not a great programmer. What you could do is have it set a variable to "1" when it is pushed, and then "0" on release. Then only have the action run if the var is 0. Does that makes sense?

I suck at this AS stuff, sorry. Just an idea. I bet someone else will come along to help better. :)


BBS Signature
Erty
Erty
  • Member since: May. 22, 2009
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to Frustrated !! Single Key Press 2009-10-16 16:37:08 Reply

I haven't tried this method yet, but I think it should work (just put it into a movieclip):

onClipEvent(load) {
urrh = true; // Just a random variable name.
}
onClipEvent(enterFrame) {
	if(Key.isDown(Key.SPACE) && urrh) {
		urrh = false;
		// Whatever function you want to trigger or variable you want to change.
	} else if(!Key.isDown(Key.SPACE)) {
		urrh = true;
	}
}

I think this should work.


Bananular.

BBS Signature
Lidve
Lidve
  • Member since: Dec. 21, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Frustrated !! Single Key Press 2009-10-16 16:47:10 Reply

(!Key.isDown(Key.SPACE))

i think thats part i was missing whole time because i didnt know about it!!

this might work now, thx a bunch

Erty
Erty
  • Member since: May. 22, 2009
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to Frustrated !! Single Key Press 2009-10-16 16:51:31 Reply

At 10/16/09 04:47 PM, Lidve wrote: (!Key.isDown(Key.SPACE))

i think thats part i was missing whole time because i didnt know about it!!

this might work now, thx a bunch

Ah, that exclamation mark only says "When this is false".
So basically !Key.isDown(Key.SPACE) can be translated to When SPACE is NOT down.


Bananular.

BBS Signature
Lidve
Lidve
  • Member since: Dec. 21, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Frustrated !! Single Key Press 2009-10-16 16:53:08 Reply

itt wooooookkrkkssss so far amaaazing "!!!

thanks and sorry for wild behaviour i am so happy because i was so frustrated whole time trying to figure simple method

Erty
Erty
  • Member since: May. 22, 2009
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to Frustrated !! Single Key Press 2009-10-16 17:00:22 Reply

At 10/16/09 04:53 PM, Lidve wrote: itt wooooookkrkkssss so far amaaazing "!!!

thanks and sorry for wild behaviour i am so happy because i was so frustrated whole time trying to figure simple method

No problem. Just ask if you want any more help.


Bananular.

BBS Signature