Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Movie Clip 1

Status
Not open for further replies.

copper

IS-IT--Management
May 10, 2001
35
0
0
US
I have a movie on frame 1, i want to play it twice before moving on to frame 2.

inside my mc on the last frame i have an action the tell the movie togo to frame 2 on the main timeline, "_parent.gotoandstop(2)" this work but it ran the mc only once before going to frame 2.

how do i run the mc twice (or maybe more) before going to frame 2.

thanks in advance
 
What you need to do is create a variable for your movieclip on the first frame. Like a counter. This is really simple even if you don't know much actionscript.
This is what you do. You make a variable, lets call it "counter". Its starting value will be 0. Then tell it to increase each time the first movie clip has played. Then just put a if statement once the counter has reached the amount of times you want the first movie to play. So the code would look like this.

On the end of the lastframe of the first movieclip:

------------------
counter = counter + 1; // increases counter by one
if (counter < 2){
this.gotoAndPlay(1);
}
else{
_parent.gotoAndStop(2);
}
------------------
what this is saying is that if the movie clip has played less than two times than it needs to be played again. This is kept track with the variable counter. And if it has played twice (with the else) then tell the main time line to gotoAndStop(2); to play your second moveclip.

You could replace the 2 with any number you want depending on how many times you want the first movieclip to play. Let me know if it works for you.

defkon2012
enjoy the dog days of human consciousness


 
If you add something like the following to your movie clip's action, it should work:

Right-click the movie clip on stage and add this script:

onClipEvent (load) {
_root.count = 0;
}
onClipEvent (enterFrame) {
if (_root.count == 60) {
_root.gotoAndStop (2);
}
_root.count++;
}

This would repeat a 12 frames movie clip for 5 times before it moves the main movie to frame 2.
The if statement is based on a 12 frames per second main movie thus 5 times 12 = 60.

Regards,
new.gif
 
Defkon2012...

If you set the variable (counter) on the first frame of the movie clip, and in your if statement, keep sending it back to frame 1, the counter will be re-initialize to 0 each time, and the main movie will never advance!

Your script on the last frame of the movie clip works on it's own, to need to initialize the counter on frame 1!

Regards,

new.gif
 
Could you not insert a dummy frame as frame 1... set the counter to &quot;0&quot; on the first frame? You could then send the playhead back to the beginning of the loop (frame 2) if the counter was <2. Causing it to skip frame 1 and go directly to frame 2. This would fix the re-initialization problem if one wanted to use a method such as the one defkon2012 has suggested.

just a thought...

Ya' Gotta Love It!
sleepyangelsBW.jpg
 
thanks oldnewbie,
it work fine.

thanks also defkon and jeff
 
Jeff, yes your method would work! But there's really no need to set the variable on the first frame anyways!
Defkon's script on the last frame will do the trick on it's own.

Regards,
new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top