-
Looping help Please help me!
ok so what Im dong is looping a movie and it is suposed to loop 3 times then stop. but when I use the script I have the only thing that stops is the main movie. any other movie clips keep animating so I figured I should put the same script inside the movie clip. but it doesnt work. the script im using looks like this
in the first frame
onLoad = function(){
loopCount = 0;
}
then in the last frame I put this
loopCount++;
if(loopCount == 3){
stop();
}
So my question is in order to get my movie clips to stop after looping three time should I be using a differnt script for the movie clips?
hellllllllllllllllllllllllllp
-
Total Universe Mod
1) you dont need to put 'please help me' in your titles, we're here to help.
2) you dont need a function just to declare a variable, you can just use:
loopCount = 0;
That will create a variable and assign an initial value at the same time. But, you will want to say:
this.loopCount = 0;
so that each movieclip has their own loopCount to look at.
Your code for the last frame need only add the this's too.
Code:
//frame 1
this.loopCount = 0;
//last frame
this.loopCount++;
if(this.loopCount == 3){
stop();
}
-
Flash Video Moderator
onLoad is best used with Classes and components, but setting the initial parameter in a function is not a bad idea. If your desire is to loop, and the frame where the parameter is set is crossed, it will reset to 0 - defeating the purpose.
You could just put everything in one function - and call it on the last frame.
Code:
// goes on first frame
function checkLoop(loops:Number):Void
{
if (this.loopsCompleted == undefined){
this.loopsCompleted = 1;
} else {
this.loopsCompleted++;
}
if (this.loopsCompleted > loops){
this.stop();
executeAnotherFunction();
}
}
// on last frame
checkLoop(3)
Last edited by Wheels; 10-07-2006 at 01:08 AM.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|