PDA

View Full Version : Basic Scene Looping


shavetheworld
02-13-2008, 08:00 PM
I am absolutely new to Actionscript, and I have a, probably, ridiculously easy question.

I have a scene (firstScene). This scene wants to be looped 4 times, then stopped on the last frame.

Thanks in advance!

stompwampa
02-13-2008, 08:27 PM
at the last frame of the loop, put this:


var loopTime:Number;

loopTime = 0;

if(loopTime != 4) {
loopTime++;
goToAndPlay(1);
}
if(loopTime = 4) {
stop();
}

shavetheworld
02-13-2008, 08:49 PM
That didn't work. Doing a trace statement showed me the problem. loopTime keeps initializing every time the animation runs.

stompwampa
02-13-2008, 09:00 PM
duh....I didn't think about that....everytime it gets to that frame, it will reset to 0....

MikeTheVike
02-13-2008, 09:02 PM
That didn't work. Doing a trace statement showed me the problem. loopTime keeps initializing every time the animation runs.

maybe take stomp's code and put the loopTime = 0 on frame 1 of loop, then start the loop animation on frame 2...then change the gotoAndPlay to frame 2 (gotoAndPlay(2)) That way it won't reset it to 0 every time.

shavetheworld
02-13-2008, 09:10 PM
Awesome, worked perfectly. Little ingenuities. Thanks again, fellas.

stompwampa
02-13-2008, 09:14 PM
yep, that's actually exactly what I was gonna suggest before I had to run to the bathroom ;-)