View Full Version : Controlled Loops. How, please?
FranksBank
09-25-2004, 05:05 PM
I have a Flash MovieClip that I want to make loop in the middle three or four times and then carry on to the end of the timeline. How can I do it? Using Flash 5 by the way.
I can obviously make the loop indefinate just by GotoAndPlay, which is how it is at the moment, but I want to enhance it by adding a 'finishing touch' after the loop has served its purpose.
Any advice greatly appreciated!
Cheers
Hi,
There are several ways to create loops. It sounds like for your situation a simple variable will work.
Example..... say I have a movieclip 10 frames long and I want it to loop on frames 5 through 8 three times before playing to the end.
Create a variable to hold the count.....
_root.playNum = 1;
On frame 8, check the variable in an if statement and increment it by one...
if(_root.playNum<3){
_root.playNum++;
_root.mcName.gotoAndPlay(5);
}else{
_root.mcName.play();
}
FranksBank
09-26-2004, 09:35 AM
Ah ha, now that makes sense. I guess I should have come up with it myself (must be getting lazy).
Many thanks, although one last ridiculous question on the matter:
Where do I place the variable?
I haven't used ActionScript in any real depth before so am really at the bottom of the learning curve in this respect. Once I've got this to work, it will open many a door for me I'm sure.
Cheers
FB
Hi,
Put it on the first frame of your movie. The code uses absolute paths(_root) to access and increment the variable each time the if statement is encountered in the movieclip frame. Also, I used a frame number, but frame labels make manageing navigation much easier.....
if(_root.playNum<3){
_root.playNum++;
_root.mcName.gotoAndPlay('frameLabel');
}else{
_root.mcName.play();
}
FranksBank
09-30-2004, 07:43 PM
NTD, my thanks to you for your help. I've got my head around the code now and have successfully put it in place. If you'd like to take a look at the resultant animation, it's on my website homepage at www.franksbank.co.uk (there's an index page first, so just 'come on in' from there) and appears after a couple of seconds of the page loading. It's just a guy hanging around for no real reason, but mildly entertaining perhaps.
Anyway, just wanted to say thanks again for your help.
Cheers
FB
Cool animation! :D
Regards
NTD
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.