View Full Version : Simple arrow question
ar
April 5th, 2005, 09:18 PM
I have this code on a movie clip:
onClipEvent (enterFrame) {
this.gotoAndStop ()
if (Key.isDown(Key.DOWN)) {
this.gotoAndPlay ()
}
}
But the problem is, when I let go of the arrow key, the movie keeps on playing. How could I make this work, so that the movie clip would go to the first frame when you let go of the arrow key?
Because this code didn't work:
onClipEvent (enterFrame) {
this.gotoAndStop ()
if (Key.isDown(Key.DOWN)) {
this.gotoAndPlay ()
} else {
this.gotoAndStop (1)
}
}
I just don't know how to set the true and false statements. Could someone help me?
Thanks in advance
!GB! - PEACE -
nathan99
April 5th, 2005, 09:27 PM
what exactly do you mean?
do u have a fla?
ar
April 5th, 2005, 09:35 PM
Actually, thanks. I checked over the code, and I tested the movie again, and it worked, but with a slight bug, but that's okay. Thanks anyway Nathan.
!GB! - PEACE -
nathan99
April 5th, 2005, 09:41 PM
oh ok,
you could have tried
onClipEvent (enterFrame) {
this.gotoAndStop();
if (Key.isDown(Key.DOWN)) {
this.gotoAndPlay();
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.DOWN) {
gotoAndStop(1);
}
}
however, i don know the code you are using so yeah
ar
April 5th, 2005, 09:48 PM
I have a new problem. The code above worked. The thing is, whenever I press down, it works fine, but when I let it go and press it again, it doesn't do anything. How could I fix that?
Thanks in advance.
!GB! - PEACE -
ar
April 5th, 2005, 09:51 PM
oh ok,
you could have tried
onClipEvent (enterFrame) {
this.gotoAndStop();
if (Key.isDown(Key.DOWN)) {
this.gotoAndPlay();
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.DOWN) {
gotoAndStop(1);
}
}
however, i don know the code you are using so yeah
I've tried that and it has the same problem.
Thanks
!GB! - PEACE -
ar
April 5th, 2005, 10:26 PM
Another question. How do you make it to where, for instance, you press the up and right arrow keys at the same time, it does that same code that was shown in the first post? Where, when you press right, it does it's own thing, you press up, same with it, but you press them both, and do something different, without that code interfearing with the others. This is what I have for my character:
onClipEvent (enterFrame) {
speed1 = 7
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop (4)
_x+= speed1
}
// I can't get this one to work
if (Key.isDown(Key.RIGHT, Key.UP)) {
this.gotoAndStop (9)
_x+= speed1
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop (3)
_x-= speed1
}
if (Key.isDown(Key.UP)) {
this.gotoAndStop (2)
// later change this so that yoshi could look like he's walking with depth
_y-= speed1
}
if (Key.isDown(Key.DOWN)) {
this.gotoAndStop (1)
// later change this so that yoshi could look like he's walking with depth
_y+= speed1
}
}
If someone changes it, I want another set, where when you press the two keys at the same time, without changing the layout of the code.
Thanks in advance.
!GB! - PEACE -
nathan99
April 5th, 2005, 10:33 PM
post a fla
nathan99
April 5th, 2005, 11:23 PM
i dont really understand what u mean about that last bit
ar
April 15th, 2005, 07:56 PM
Here is the fla.
I don't understand how to make all of his movements move good, so when you press two arrow keys at the same time, the speed changes and it goes to another frame within the movie clip.
I'm sorry, the fla is too large to fit.
But if you understand the question, then could you help me out?
thanks
!GB! - PEACE -
ar
April 15th, 2005, 08:14 PM
LINK (http://es.voetsjoeba.com/characters.swf)
There's the movie thing that I'm trying to get done right.
I don't understand. When I press up + right, and other combinations, I want the speed to change and so that the frame, inside of the movie clip, goes to frame 9.
I want it to where you press both arrow keys, the other codes are canceled out, so that it doesn't read the single direction codes.
I need help
Thanks
EDIT: for some reason you can't move the character from this site. So There's a link to the file.
Also as you see, when you press an arrow, let it go then press it again, it doesn't animate or anything, it just stays still.
You can download the fla HERE (http://es.voetsjoeba.com/characters.fla) it's 500 + kb
!GB! - PEACE -
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.