INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*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
Partner Button
(Download This Button Today!)

Member Feedback

"...If there has ever been a justification needed for access to the net during working hours, just referring to this site should suffice. Fantastic!..."

Geography

Where in the world do Tek-Tips members come from?
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
Check Out Our Whitepaper Library. Click Here.
defkon2012 (Programmer)
1 Feb 02 15:02
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


Helpful Member!oldnewbie (TechnicalUser)
1 Feb 02 15:04
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,

Helpful Member!oldnewbie (TechnicalUser)
1 Feb 02 15:15
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,

 

TulsaJeff (Programmer)
1 Feb 02 15:27
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
Helpful Member!oldnewbie (TechnicalUser)
1 Feb 02 18:37
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,

Start A New Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: Adobe(Macromedia): Flash Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=250
DESCRIPTION: Adobe(Macromedia): Flash technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.