PDA

View Full Version : Making the animation loop



Mr.Pancake
February 13th, 2005, 09:02 AM
Sorry for the many treads if posted, but im a hard worker ;).

ok now i need to know is:

I have a moviclip that contains a guy that is walking, i made a stop(); action

In the first frame. on the movieclip actions i wrote:

onClipEvent (load) {
speed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation += 20;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 20;
}
if (Key.isDown(Key.UP)) {
_y -= speed*Math.cos(_rotation*(Math.PI/180));
_x += speed*Math.sin(_rotation*(Math.PI/180));
}
if (Key.isDown(Key.DOWN)) {
_y += speed*Math.cos(_rotation*(Math.PI/180));
_x -= speed*Math.sin(_rotation*(Math.PI/180));
}
}

if i put a gotoAndPlay() action like this:
if (Key.isDown(Key.UP)) {
_y -= speed*Math.cos(_rotation*(Math.PI/180));
_x += speed*Math.sin(_rotation*(Math.PI/180));
gotoAndPlay(2)}
if (Key.isDown(Key.DOWN)) {
_y += speed*Math.cos(_rotation*(Math.PI/180));
_x -= speed*Math.sin(_rotation*(Math.PI/180));
gotoAndPlay(2)}
}

it wil play the animation but if u hold the (key UP) it wil stop at the first frame

How can i make it so it will loop without releasing the up key?


Thnx in advance Pancake

Inferno
February 13th, 2005, 09:18 AM
Try putting play action to the first frame..

e-sarbak
February 13th, 2005, 11:51 AM
Dont worry for posting much threads ...:)

mixedtrigeno
February 13th, 2005, 01:38 PM
post ur fla

eiefai
February 13th, 2005, 02:27 PM
try this


if (Key.isDown(Key.UP)) {
_y -= speed*Math.cos(_rotation*(Math.PI/180));
_x += speed*Math.sin(_rotation*(Math.PI/180));
play();
} else if (Key.isDown(Key.DOWN)) {
_y += speed*Math.cos(_rotation*(Math.PI/180));
_x -= speed*Math.sin(_rotation*(Math.PI/180));
play();
} else {
stop();
}

Mr.Pancake
February 14th, 2005, 06:31 AM
thnx that helped :)