Be a Supporter!

Key Up actionscript

  • 679 Views
  • 4 Replies
New Topic Respond to this Topic
JOECANl
JOECANl
  • Member since: Feb. 20, 2009
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Key Up actionscript 2009-02-21 08:35:31 Reply

Im Currently making some in flash where when i realse the left key i want a MC to go to a certain frame i tried something like

- on (Key.onKeyUp (Key.LEFT)) {_root.Character.gotoAndStop(1);} -

but didnt work i then checked the net with little help and was wondering if anyone could tell me the the right mouse event code that i would need :P


Safe Darlin' :P

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Key Up actionscript 2009-02-21 08:59:03 Reply

Best bet is a key listener. These actions on a frame on the main timeline:

kl=new Object();
kl.onKeyDown=function(){
	if(Key.getCode()==32){  //SPACEBAR
		//DO STUFF
	}
}
kl.onKeyUp=function(){
	if (Key.getCode()==32){ //SPACEBAR
		//DO STUFF
	}
}
Key.addListener(kl);

If you need to know the keycodes for left, right etc, you can use this thingy


- - Flash - Music - Images - -

BBS Signature
adam2510
adam2510
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Key Up actionscript 2009-02-21 09:00:01 Reply

on (keyPress "LEFT") {
_root.Character.gotoAndStop(1);
}

that key syntax doesnt exist


Web Hosting: Free! Premium!

BBS Signature
adam2510
adam2510
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Key Up actionscript 2009-02-21 09:01:37 Reply

what i meant is

Key.onKeyUp doesnt exist


Web Hosting: Free! Premium!

BBS Signature
JOECANl
JOECANl
  • Member since: Feb. 20, 2009
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Key Up actionscript 2009-02-21 09:22:22 Reply

kl=new Object();
kl.onKeyDown=function(){
if(Key.getCode()==32){ //SPACEBAR
//DO STUFF
}
}
kl.onKeyUp=function(){
if (Key.getCode()==32){ //SPACEBAR
//DO STUFF
}
}
Key.addListener(kl);

Beautiful mate it works perfectly now thank you so much :P


Safe Darlin' :P