|
-
Flash Intermediate
KEY_DOWN Problems
Hey everyone! I have a virtual joystick that I am making for one of my games, and I'm having a problem with the KEY_DOWN command. Here's my code so far.
Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, joyKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, joyKeyUp);
function joyKeyDown(joyEventGo:KeyboardEvent):void {
if (joyEventGo.keyCode==Keyboard.LEFT) {
joystick.gotoAndPlay(2);
}
}
function joyKeyUp(joyEventStop:KeyboardEvent):void {
if (joyEventStop.keyCode==Keyboard.LEFT) {
joystick.gotoAndPlay(1);
}
}
My problem is that I cant seem to get it to stop looping. I have a joystick in normal position in frame 1 of the joystick MC, and other positions in the other 4 frames.
Here's what my code makes the joystick do.
\ / \ / \ / \ / \ / \ / \ / \
it flashes back and forth. I cant get it to stop pinging the function for gotoAndPlay, so it wont stop going to the right position.
Can someone please fix my code?
Thanks, Xen Element
In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.
---
Check out my blog at XenElement.com
-
Have you tried gotoAndStop()?
-
Flash Intermediate
Wow. It didn't work before, but I just tried it now and it worked! Thanks so much!
In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.
---
Check out my blog at XenElement.com
-
Flash Intermediate
The answer was, gotoAndStop(), because the stop part does not override the stop already in the MC frame like the gotoAndPlay() did.
Thank you very much, I can't believe I didn't see this before!
In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.
---
Check out my blog at XenElement.com
-
You probably want gotoAndStop instead of gotoAndPlay.
Also, if you are holding down your key, then the operating system will start sending repeated keypresses after a short delay. You could remove the listener until the KeyUp is detected.
Edit:
I'm slow on the draw today.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|