PDA

View Full Version : Actions continue after key is released



wham
October 21st, 2005, 11:02 PM
onClipEvent (enterFrame) {
with (_root.shuttle) {
mySpeed = 40;
myRot = 15;
asky = Key.getAscii();
if (Key.isDown(Key.DOWN) || asky == 115) {
_y += mySpeed;
}
else {
_y += 0; }
This is a portion of the code for a game I am trying to make.
I am trying to make a movie clip move whenever the W,A,S,D or
arrow keys are pressed. For some reason, whenever I press the W,A,S or D keys, it moves and won't stop instead of moving only once. I am pretty sure that I need to use the Key.isDown for this, but whenever I put "115" (the ascii keycode for S), or Key.isDown(Key.S), it doesn't do anything. Any ideas on the proper syntax?
Thanks in advance.

nathan99
October 21st, 2005, 11:56 PM
maybe u should not only use get ASCii

nathan99
October 21st, 2005, 11:57 PM
http://www.kirupa.com/forum/showthread.php?t=195182

wham
October 22nd, 2005, 05:11 PM
Thank you. Works great now. :beer: