INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...this web site is a 'Godsend' for me. If I have a programming problem that I'm unable to solve, I'll get a sensible reply in no time. It's really great!..."
Geography
Where in the world do Tek-Tips members come from?
|
Movie Clip
|
|
|
copper (IS/IT--Management) |
1 Feb 02 14:29 |
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, 
|
|
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, 
|
|
Could you not insert a dummy frame as frame 1... set the counter to "0" 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!
|
|
|
copper (IS/IT--Management) |
1 Feb 02 15:38 |
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, 
|
|
|
 |
|
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close