sure, try here http://casalib.org/blog/using-the-key-class/
On 10/07/2009, justaddice <[email protected]> wrote: > > Thanks.. Is there any documentation to help using that class? > > Cheers. > > > > On Jul 10, 1:57 pm, katopz <[email protected]> wrote: >> this should >> helphttp://svn.as3.casalib.org/releases/latest/code/org/casalib/ui >> >> hth >> >> On 10/07/2009, justaddice <[email protected]> wrote: >> >> >> >> >> >> >> >> > I guess this might be more of a general Flash AS3 question, however it >> > applies while I'm attempting to make a game using Away3D, so I'll post >> > it here and hope someone can help me out... >> >> > My game is designed such that I use the arrow keys and space bar. I've >> > noticed that if I'm pressing UP and RIGHT at the same time, and then >> > press SPACE, everything is ok (my ship fires), however using UP LEFT >> > and then SPACE wont trigger the keydown event (my ship dosn't fire)... >> >> > If it helps here is the code I'm using (nicely wrapped in a package): >> >> > package >> > { >> > import flash.events.KeyboardEvent; >> >> > public class keys >> > { >> > public const LEFT_ARROW:int = 37; >> > public const RIGHT_ARROW:int = 39; >> > public const UP_ARROW:int = 38; >> > public const DOWN_ARROW:int = 40; >> > public const SPACE_BAR:int = 32; >> > public var keysTracked:Array; >> >> > public function keys(movieclip) >> > { >> > keysTracked = new Array(); >> > >> > movieclip.stage.addEventListener(KeyboardEvent.KEY_DOWN, >> > keyDownHandler); >> > >> > movieclip.stage.addEventListener(KeyboardEvent.KEY_UP, >> > keyUpHandler); >> > } >> >> > public function trackKey(keyCode:int):void >> > { >> > keysTracked[keyCode] = false; >> > } >> >> > public function unTrackKey(keyCode:int):void >> > { >> > keysTracked[keyCode] = undefined; >> > } >> >> > public function isKeyDown(keyCode:int) >> > { >> > return keysTracked[keyCode]; >> > } >> >> > function keyDownHandler(event:KeyboardEvent) >> > { >> > if(keysTracked[event.keyCode] != undefined) >> > keysTracked[event.keyCode] = true; >> > } >> >> > function keyUpHandler(event:KeyboardEvent) >> > { >> > if(keysTracked[event.keyCode] != undefined) >> > keysTracked[event.keyCode] = false; >> > } >> > } >> > } >> >> -- >> katopzhttp://www.sleepydesign.com -- katopz http://www.sleepydesign.com
