PDA

View Full Version : animation loops via script?


eposos
07-25-2005, 04:43 PM
Hi -

heres a simple question that I would really appreciate someone helping me with: Is there a way to create a looping effect for a MC via a script?

The idea is to:
press button 01 = movieclip plays and loops (no looping set in mc itself)
Press button 02 = same movie clip continues to play but stops at end of timeline - does not loop.

a button initiates mc play - (does the script live here somewhere?):

on (press) {
_root.play();
_root.mymovie_mc.play();
}


Thanks!

Ricod
07-25-2005, 05:32 PM
Welcome to AS[org] !

Actually, movieclips loop by default. If you want it to be controlled by a button, the easiest way is to set an if statement on the last frame of your mc :
if (button_pressed==2){
stop();
} else {
gotoAndPlay(2);
}
Now, if you have a stop()l on your first frame as well, the mc doesn't play. Your buttons could have code like :
//button 1 code
on (release) {
_root.my_Mc.gotoAndPlay(2);
_root.my_Mc.button_pressed = 1;
}
//button 2 code
on (release) {
_root.my_Mc.gotoAndPlay(2);
_root.my_Mc.button_pressed = 2;
}