Looping a movie clip a specific number of times in Flash

Does anyone know how to get a movie clip to loop a specific number of times in Flash? I know how to stop a movie clip from looping by using the this.stop (); command by placing the command in a separate Action Script layer, in a keyframe, inside of the movie clip's timeline. This allows the movie clip to play through once and then stop. But I need for the movie clip to loop more than once, maybe 2 or 3 times, and then go back to the main timeline. Does anyone know the code for this?
Also, is it possible to place a pause (I'm guessing, maybe by using a timer of some type?) between the loops, so that the movie will pause a couple of seconds before it loops again and then stop? Please note I do not need the movie clip to stop when there's an event like a rollover or anything. I just need it to play a couple of times, pause between plays and then stop and go back to the main timeline. Please let me know if anyone can help.
Thanks,
Sarah
P.S. Is there a good, easy to use, reference book anyone can recommend for creating specific things in Flash using Action Script? Do you guys have a favorite for beginners like me?

You can use a variable to keep count of how many times you loop, and until it exceeds a particulr value (2 or 3) you execute a setTimeout() call that waits for however long you want to delay and then tells the movieclip to gotoAndPlay(1).
So in the first frame you would establish the counting variable...
var count;
if(count == undefined){ // only set it to 0 once
count = 0;
and in the last frame you would do your incrementing and control....
stop();
count += 1;
if(count < 3){
setTimeout(waitABit, 2000); // call function in 2 secs
function waitABit(){
gotoAndPlay(1);

Similar Messages

  • Looping Background Movie Clip

    Hi i am having trouble with having a looping background movie
    clip on the bottom layer of my flash project. I have it on the
    bottom layer in the first frame, above it i have some menus fading
    in and it seems as though once it gets to this scene, it just plays
    the movie clip over and over and never goes to the 2nd frame of my
    scene. Is there anyway to have a looping background movie clip
    inside of flash 8?
    Thank you in advance,
    Tyler

    You can use a variable to keep count of how many times you loop, and until it exceeds a particulr value (2 or 3) you execute a setTimeout() call that waits for however long you want to delay and then tells the movieclip to gotoAndPlay(1).
    So in the first frame you would establish the counting variable...
    var count;
    if(count == undefined){ // only set it to 0 once
    count = 0;
    and in the last frame you would do your incrementing and control....
    stop();
    count += 1;
    if(count < 3){
    setTimeout(waitABit, 2000); // call function in 2 secs
    function waitABit(){
    gotoAndPlay(1);

  • Repeat a specific number of times

    I have 6 frames on my movie timeline. Each frame has a movie
    about 200 - 300 frames.
    I want each movie to repeat a specific number of times before
    it goes to the next frame on the main movie time line.
    How can I do this

    Look at this:
    http://www.smithmediafusion.com/blog/?p=19
    Change this:
    if(myCount ==3){
    stop();
    to:
    if(myCount ==3){
    gotoAndPlay(nextMovieFrame);
    Dan Mode
    --> Adobe Community Expert
    *Flash Helps*
    http://www.smithmediafusion.com/blog/?cat=11
    *THE online Radio*
    http://www.tornadostream.com
    *Must Read*
    http://www.smithmediafusion.com/blog
    "umr" <[email protected]> wrote in message
    news:ed1ug9$41o$[email protected]..
    >I have 6 frames on my movie timeline. Each frame has a
    movie about 200 -
    >300
    > frames.
    > I want each movie to repeat a specific number of times
    before it goes to
    > the
    > next frame on the main movie time line.
    >
    > How can I do this
    >

  • How to replay( looping ) a movie clip which animated by action script?

    My movie clip has only one frame, I animate it by using
    action script.
    How can I looping its animation?

    quote:
    Originally posted by:
    dzedward
    if you're using the Tween class, listen for onMotionFinish
    (as2) or MOTION_FINISH (as3) to start the tween over.
    no, my movie clip was animated by using for loop. What I want
    to do is no matter where I put my movie clip, it will contnuously
    move from left to right.

  • How do I loop a movie clip?

    I have a 15 sec. movie clip of a burning fire. I need to stretch or loop the clip to about 12 minutes long. But how do I do that in iMovie. I would like a smooth transition between the loops.
    (Using my old Mac with iMovie HD 6)

    iMHD6 supports copy/paste..
    select the clip, Apple-C, Apple-V .. 30sec
    select both clips, Apple-C, Apple-V .. 60sec
    select all clips, Apple-C, Apple-V .. 2min
    select all clips, Apple-C, Apple-V .. 4min
    select all clips, Apple-C, Apple-V .. 8min
    select all clips, Apple-C, Apple-V .. 16min ooops ..
    add dissolves +al gusto+ ..

  • How to move clip one frame at a time or nudge

    Tried searching this, as I'm sure it's basic and in the owner's manual, but I can't find it:
    I can't control how far I'm dragging something across the timeline. Can I grab and nudge rather than grab and drag? I'd like to be able to move a clip one frame over.
    Thanks.

    If there's nothing in the way you can use the [ and ] keys or comma and period. Shift-bracket will move five frames.

  • Looping movie clips

    I want to loop 5 movie clips so that one clip moves onto the stage, stays there for a certain time, then moves off the stage, then the next one.
    Any help is greatly appreciated!
    Here's what I've got so far:
    var m1_mc = new m1();
    var m2_mc = new m2();
    var m3_mc = new m3();
    var m4_mc = new m4();
    var m5_mc = new m5();
    currentPage = m1_mc;
    var timer:Timer = new Timer(1000);
    timer.addEventListener(TimerEvent.TIMER, onTimer);
    timer.start();
    function onTimer(evt:TimerEvent):void {
    for (var i:Number = 0; i<5; i++){
    prevPage = currentPage;
    var exitTween:Tween = new GCSafeTween(currentPage,"x",Strong.easeOut,currentPage.x,-800,12,false);
    //this is where I am getting stuck. Not sure how to write currentPage + 1 to make the next movie clip play
    exitTween.addEventListener(TweenEvent.MOTION_FINISH, animateOn);
    function animateOn(e:TweenEvent):void{
    var enterTween:Tween = new GCSafeTween(currentPage,"x",Strong.easeOut,-800,0,12,false);

    You should probably step back and rethink things a bit, though not entirely, possibly take it one step at a time.  Get one piece to play properly, then work in having 5 of them.  Using the tween event listeneres amd the timer to trigger things is a good approach.
    Tween-In -> Timer -> Tween-Out -> next Tween-In...
    That for loop inside the function will execute immediately, creating 5 tweens for the currentPage, etc... which is not what I think you want.
    Use a counter variable to keep track of which mc you are dealing with and use it/increment it to define which mc you are dealing with...
    var mcNum:uint = 1;
    var currentPage:MovieClip = this["m"+mcNum+"_mc"];
    and don't forget that you need to add the instances to the movie before you can expect them to be present/visible in any way (addChild())

  • Dynamic text in looping movie clip

    Hi,
    I am looping a movie clip which has a dynamic text box. I
    need to call data from XML and place the same in the Dynamic text
    box as per the duplicated movie clip. how do i do that.
    Thanks,
    Ayush

    on (release) {
    _parent.frontFields.topTextArch.ph2TopTextBrush._visible =
    false;
    That is the script attached to my button. I can see the text
    flash for a second when I push the button but it does'nt go away
    because the looping movie clip just continually goes back to the
    first frame and makes the ph2TopTextBrush text field visible again.
    I think I know what your saying. Your saying to attach a
    script to the first frame of the looping movie clip that would
    check to see which of the 3 dynamic text fields are visible. That
    would be perfect but I'm not sure how to do it.
    What would the script that I place on my button look like?
    What would the script in the first frame of the looping movie clip
    look like?

  • I Can't stop my movie clip from looping

    This is probably an easy fix, but I obviously can't get it. Below is the actionscript to loop my movie clip, but once it's activated, I can't get it to stop. I thought it would stop at 3. What did I miss??
    Any help? Flash 8 (CS2).
    on (rollOver){
        for (i=0; i<=3; ++i){
            audio_mov.duplicateMovieClip("audio_mov" +ii);

    remove the stop() from the first frame of blur and assign your button an instance name (eg, btn).  then see if this does what you want:
    blur.stop();
    var tl:MovieClip=this;
    btn.onRollOver=function(){
    blur.play();
    btn.onRollOut=function(){
    tl.onEnterFrame=function(){
    if(blur._currentframe==1){
    blur.stop();
    delete this.onEnterFrame;

  • MOVIE CLIP

    Once I select all the input fields along with titles, I
    create the new movieclip and name it form. This will be the form
    movieclip. And do I check 'Export for Actionscript' in the linkage
    area? Perhaps, I did not do that prior.

    Mary Alice,
    > Whoops. No variable name for the FORM, only an instance
    of
    > name: FORM. And it does not seem to have an instance
    name.
    First all, I need to clarify a major typo in my last post. I
    totally
    destroyed the object reference I've been trying to explain,
    so please accept
    my apologies, and I hope my current reply will clarify
    matters.
    Because your path contains the expression "form_mc," the
    instance name
    of that movie clip -- the one that's holding all the text
    fields -- needs to
    be form_mc (because that's the name in your path).
    Think of this in terms of folders on your hard drive; it's a
    great
    analogy to what's going on here. That button interprets the
    ActionScript
    object reference like this: "From my own point of view
    (this), I'll look up
    one 'folder' to the timeline I'm in (_parent). From there,
    I'll look look
    for an object with the instance name form_mc. That movie clip
    contains a
    number of nested objects, one of whose instance names is
    household_txt.
    That nested object is a text field, which means it has a text
    property.
    That's what I want." So, string those all together and you
    get:
    this._parent.form_mc.household_txt.text;
    That's the location of one of the text fields from the point
    of view of
    the ActionScript associated with your button. In my last
    reply -- I'll
    blame it on a lack of coffee today (lame excuse!) -- I put
    that object
    reference (that "folder path," if you will) in the wrong
    place.
    Consider what you're after, though, it it should make sense.
    Since the
    ActionScript is associated with the button, everything must
    be taken from
    the button's point of view. The LoadVars instance is created
    inside the
    button, so from the button's point of view, the LoadVars
    instance (my_lv) is
    right there.
    e.g.
    on (release) {
    my_lv = new LoadVars();
    re_lv = new LoadVars();
    So far, so good. If you want to refer to my_lv or re_lv
    again while
    inside this on() handler, no object path is necessary. If you
    wanted to,
    you could use this.my_lv or this.re_lv, but even without the
    "this," the
    path to these objects is understood: they're right here. So,
    as you create
    new properties for the my_lv object, you name the object and
    its new
    property ...
    my_lv.household =
    ... and set that new property equal to the value of the
    TextField.text
    property of one of your text fields in the path we just
    covered; namely,
    this._parent.form_mc.household_txt.text. So ...
    my_lv.household = this._parent.form_mc.household_txt.text;
    ... and so on, with the rest of them:
    my_lv.water = this._parent.form_mc.water_txt.text;
    my_lv.soft = this._parent.form_mc.soft_txt.text;
    // etc.
    Does that clear it up?
    Note: even after you update all of this, you may still run
    into
    problems, so keep your chin up. There's a lot going on here,
    and you'll
    need to work through each concept until you get it. The
    concept we're
    working toward right now is object references.
    > Or, is instance of the same as instance name?
    The term instance refers to an object made from a template.
    If you use
    the drawing tools to create some artwork and convert that
    artwork into a
    movie clip, a new movie clip symbol will appear in your
    Library panel. You
    can drag as many copies of that movie clip symbol to the
    Stage as you like.
    Doing so means you're creating that many "instances of" the
    MovieClip class;
    in particular, "instances of" a very specific movie clip in
    your Library.
    Every dynamic or input text field you create, even if it
    isn't symbol, is
    automatically an "instance of" the TextField class. Even if
    you don't give
    them instance names, they're still instances of the classes
    (the type of
    object) they represent. But without instance names, it's much
    hard to get
    ActionScript to speak directly to any of them.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • How to loop an swf a set number of times?

    I need to loop a banner animation a set number of times, then
    get it to gotoandstop on a final frame. I know in the past I could
    use:
    counter++; if (counter<5) { gotoAndPlay (1); }
    At least for the looping part (don't even know yet about the
    stop pon a particular frame part).
    but now in Flash 8 I can't get my test swf to do that using
    this statement. Am I missing something? (Of course, obviously I am
    or I wouldn't be here!)

    This works for me as well, but i don't want it to jump to the
    final still frame. i need mine to loop three times, then plan
    through to the frame i want, stopping there. the frame i want is
    not the final frame in the swf. it is somewhere in the middle.
    does that make sense?

  • How do I View Guides for Movie Clips in Relation to Entire Scene?

    My boss purchased a flash animation from a company a few months ago that she now needs me to fix. The goal is to resize the animation to different dimensions for a new banner. I took the original file, brought up the document settings, and changed the size to the new one we need, and hit the "scale content" checkbox. The file I have after doing this is shown below; I have highlighted the shape I will be talking about in pink. Nothing is the correct size now so I am trying to resize them to fit the stage area. I am having trouble with the green shape that is highlighted Pink.
    The person who originally made this file made that highlighted shape into a movie clip and then dropped it in to the main timeline. I was wondering if there was a way that I could see where that shape is in relation to the area of the entire stage and the other objects in the main timeline? Meaning if I am inside of the greenblock movie clip all I see is what is below:
    With this view I cannot tell where that shape is in relation to everything else. I am hoping someone can tell me how to view the guides from my main file inside of this movie clip( I already have guides turned on), or any other way of seeing what size and where my shape is in relation to rest of the objects on the stage of my main file. I would take any option that would let me tweak the green shape inside of the movie clip and see in real time how it looks in relation to the rest of the items on the stage as I make changes.
    Any suggestions on how to get perspective on where my movie clip is in relation to the stage and other objects on it would be greatly appreciated.
    Sincerely,
    Tissal

    Somehow double clicking on your system seems to be connected to the command
    fl.getDocumentDOM().enterEditMode('');//the view where you don`t see the rest of your stage
    whereas normally it defaults to
    fl.getDocumentDOM().enterEditMode('inPlace'); //the view where you can see everything els on stge alphablended
    you can either create a shortcut to
    edit>edit in place or alter the standard behaviour of your double click
    or right click(Windows) or ctrl-click(MAc) the mc and choose Edit in Place

  • Targeting Multiple Movie Clips

    Hi everyone,
    I'm fairly new to ActionScript so I would really appreciate
    any help I can receive.
    Right, I have a Flash file which contains a movie clip with
    an instance called, 'contentHold_mc'. Inside this movie clip are 4
    individual movie clips with instances entitled, 'content1_mc',
    'content2_mc', 'content3_mc' and 'content4_mc'. I know these are
    not the best names for instances, but this is just for simplicty's
    sake. At present all movie clips run at the same time. I want them
    to run sequentially. On the last frame of the instance,
    'content1_mc', I want to stop the instance from playing and start
    playing the instance, 'content2_mc'. On the final frame on
    'content3_mc', I want to stop the instance from playing and start
    playing the instance, 'content3_mc', and so on until 'content4_mc'
    finishes playing. I have tried to use the tellTarget function
    without success and anyway, I believe this is now deprecated.
    Would anybody be able to provide me some guidance please as
    to how I can achieve the previous using the 'dot' notation?
    I have tried the using the code found at the bottom of this
    message in the final frame of the movie clip instance that I want
    to play first ('content1_mc'), however get a compiler error because
    of the preceding two full stops '..'
    Thank you in advance for any help I may receive with this
    query.

    Put a stop(); command at the first frame of each of the
    clips. On the last frame of the first clip put:
    stop();
    _parent.contentHold_mc.content2_mc.play();
    repeat as needed for each movie clip.
    Tell the first clip to play.

  • Buttons in Movie Clips, Movie Clips in Movie Clips

    Here goes. I have a scene with a button in the timeline, that
    targets a frame in a movie clip, which is essentially the content
    area of the layout. this is the code used:
    on (release) {
    textmov.gotoAndPlay ("challenge");
    This works fine and dandy. Now the problem. Within this
    "Content" movie clip, i have another movie clip with a button in
    it. This clip is designed to tween in then upon clicking a close
    button tween out. When I test it the button doesn't have rollovers
    like and I can't get it to talk to the clip above it to play the
    close tween.

    > I am still struggling with the fact, that upon testing,
    buttons in movie clips
    > do not exhibit their various states. Up, Over etc. I'm
    relatively sure that you
    > can have buttons in Movie Clips. I've also noticed that
    any graphic symbols
    > within a Movie Clip produce the hand, when the mouse
    cursor is Over them, just
    > like a button would. All of this happens, when testing
    in the FlashPlayer.
    is there any place you could kindly upload the source file
    for me to check ?
    > Do buttons operate independently of the Movie Clip
    timeline they are placed in?
    that is correct, button should work independently to movie
    clip.
    it only react to mouse upon entering the HIT state (which is
    invisible to user)
    and stops reacting once the mouse is off that state.
    > I have one Movie Clip with a one frame time line, should
    a Button symbol work
    > it it?
    of course it should work...
    Try to upload the source, let us check it out for you, spare
    you time on guessing :)
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Visitors to Flash site post content onto movie clips?

    Can visitors to a Flash web site post content like images on
    to Flash movie clips?
    Do you know of a Flash web site that does this that I can
    visit?
    Thanks.

    What I mean is Flash capable of excepting content such as
    images posted from visitors to a Flash web site or must a server
    side program be used with Flash such as PHP or Coldfusion.
    Thanks for any advice.

Maybe you are looking for

  • Most of my built in apps are erased on my brand new ipod touch 4g, like face time and apps store . How do i get them back, like face

    i need my built in apps back . Does any one know about this ?

  • BB10 Lack of support manual set APN

    I have bought a Z10 stl100-3 directly and not from the carrier and made sure that it should work according to the frequencies and all specs in my country (Israel) but when i want to set to my operator, the APN i can't the BB10 OS doesn't save the APN

  • Layer problem with graphics

    I have a layer where on one frame I have 3 dynamic text boxes which I convert to one graphic. These are used to display a value set through actionscript whilst a motion tween fades it in and out. I have called the graphic set1 with names on each of t

  • Spry Repeat Question

    Hello, In DW I can use Repeat Region and assign how many records it will display in the repeat and then have navigation to move forwards or backwards. Is there a way to do that with a Spry Region/Repeat ? Thanks in advance of any help. Regards Ray

  • Will Lion speed up or slow down my machine?

    My Macbook has been upgraded to have 4GB of RAM a while ago and has been running fairly well for a long time. However, recently when too much is 'going on', rending out of AE and looking on the net, the system crashes and relogs me in! Very frustrati