PDA

View Full Version : looping particular frames


twiss
11-17-2007, 07:39 AM
This is probably simple for a lot of you but its doing my head in! I have 29 frames that I want to loop, however, I want to loop frames 1-15 only. So i'd want it to play frame 1 -29 the first time, then loop 1-15 infinity times. Please bear in mind I am a newbie...

Mazoonist
11-17-2007, 11:20 AM
Hey Twiss,

Well, the first thing that comes to mind would be to create a variable and name it something like firstTime. This variable will be a boolean and will indicate whether a particular pass through the frames is the first time.

You might also want to lengthen your timeline one more frame. On frame 1, set firstTime to true. But after that, you don't want to visit frame 1 again, because you only want that variable to be true one time, and coming back to frame 1 will set it to true again.

So, frame 1 exists solely to create and initialize the variable.
Frames 2-16 play continually.
Frames 17-30 only play the first time.

On frame 1:
var firstTime:Boolean = true;
On frame 16:
if(firstTime == false) {
gotoAndPlay(2);
}
On Frame 30:
firstTime = false;
gotoAndPlay(2);
When the playhead hits frame 16 on the first time through, since firstTime is not false, the inside of this if statement will be ignored and the playhead will keep going. But since firstTime gets set to false on the last frame, the next time through, and every time after that, the inside of that if statement will get executed and send the playhead back to frame 2.