Loop timeline in movieclip then gotandplay frame

Hi all,
I have an animation of a dog running across the stage and a movieclip called "legs" which is the legs moving. I want to loop the dogs legs for a certain amount of frames and then make it stop on a certain frame within that same nested "legs" movie clip.
Can anyone tell me how to do this and where the actionscript should go??
Many thanks!
Zoe

In that frame you can place a conditional that tests how many times the animation has gone thru it and then have it stop at a particular number of times.  In the example code below, it stops on the 5th time thru.
var counter;
if(counter == null){
    counter = 1;
} else {
    counter += 1;
    if(counter == 5){
        stop();

Similar Messages

  • Help with button that goes back to main timeline from movieclip

    I have a movie created that is broken down into sections on the timeline (home about contact etc)
    Each section has a movieclip
    I want to be able to be in the about movieclip and click a button that will bring you back to the main timeline contact section
    Heres is the actionscript I am using to navigate the main timeline for each section
    stop();
    //handle events for buttons...
    index.addEventListener(MouseEvent.CLICK, clickSection);
    about.addEventListener(MouseEvent.CLICK, clickSection);
    wind.addEventListener(MouseEvent.CLICK, clickSection);
    turbines.addEventListener(MouseEvent.CLICK, clickSection);
    services.addEventListener(MouseEvent.CLICK, clickSection);
    invest.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);
    function clickSection(evtObj:MouseEvent){
                    //go to the section clicked on...
                    gotoAndStop(evtObj.target.name);

    if that code is on the timeline of a movieclip whose parent is the main timeline, use:
    MovieClip(parent).gotoAndStop("frame label in main timeline");

  • Go to frame then another frame

    Hi, hope youre all well!
    I am trying to execute the following.
    Click on button 1 - play frames 1-5, then play frame 10
    click on button 2 - play frames 1-5, then 11
    click on button 3 - play frames 1-5, then 12
    I have got it so that they play frames 1-5 but I dont know how to type the code so that it plays a frame after it has played 1-5, Can anyone help?
    Thanks in advance

    you can use the function below.  it needs no changes.  to play the root timeline from 1-5, and then frame 11, use:
    // the first parameter is the movieclip you want to play.  the 2nd and all even parameters are the start frames and the parameter that follows a start frame is an end frame:
    playArrayF(MovieClip(root),[1,5,11,11]);
    function playArrayF(mc:MovieClip,a:Array){
        var tempMC:MovieClip=new MovieClip();
        var f:Function = function(e:Event){
            if(!afterJump){
                mc.gotoAndStop(a[index]);
                afterJump=true;
            } else {
                if(a[index]<a[index+1]){
                    mc.nextFrame();
                } else {
                    mc.prevFrame();
            if(mc.currentFrame==a[index+1]){
                index+=2;
                afterJump = false;
                if(index>=a.length){
                    tempMC.removeEventListener(Event.ENTER_FRAME,f);
                    tempMC=null;
        var afterJump:Boolean = false;
        var index:uint=0;
        tempMC.addEventListener(Event.ENTER_FRAME,f);

  • Navigating the Timeline from Movieclip

    Hi there
    I'm hoping someone can help me with this. I have created a
    scrolling image gallery in Flash which works fine from the Timeline
    (Scene 1). Now I am using it inside a movie clip called gallery I
    need to know how to get it to load the images into the main loading
    area now that it is within a movie clip. The code that makes the
    images load into the loading area at the moment is this
    on(press){
    _root.the_entire_gallery.gotoAndPlay("pic5");
    I'm assuming that now it is inside a movie clip I need to add
    something other than _root. to get it to access the images but I
    don't know what. I've tried _parent but to be honest I'm clutching
    at straws as I don't really understand what it does.
    Hope someone can help.
    Thanks

    Hi there
    I have tried both the solutions you suggested without any
    luck. Is there a way I can send you a copy of the fla and you will
    be able to see how it is set up?
    Perhaps a simpler example is the button inside the gallery
    movieclip, this doesn't work from inside here either it has the
    following code on it ...
    on (press) {
    _root.gotoAndStop("sketchbook");
    ...that let's it work from the main timeline but now that the
    frame label "sketchbook" is inside the gallery movieclip how do I
    get it to reference that because nothing is happening as I take it
    _root. is pointing it to the main timeline?
    I have tried on (press) { gallery.gotoAndStop("sketchbook");
    I know it all works if I don't put it into a movieclip but I
    want to have everything neat and tidy on the timeline. It would
    really help to be able to send you the fla.
    Thanks, Jo

  • I am having difficulties in maintaining a facetime connection through my ipad.  It will generally work for 20 seconds or so and then the frame freezes. It is difficult to follow our 2 year grandson. Any fixes?

    I am having difficuties in maintaining a Facetime connection through my ipad 2. It will generally work for 20 seconds or so, and then the frame freezes. Sometimes we have audio with a freeze frame picture. It is difficult to maintain the attention of a 2 year grandson anyway, but the the lost connections make it impossible. Any fixes?

    This is a connection problem with wifi.   Either your wifi is failing, or your internet service is not fast enough for video feed.

  • Embedded video plays and then shows frame one at end.

    Hi,
    I have an embedded video that is approx 500 frames. It plays through but at the end, when it stops, it shows frame 1. At the end of the video I have placed stop();
    Any ideas on how to get it to stay at the last frame at the end?
    Thanks for any help.

    If you are playing the video in the timeline, shorten the number of frames that the video occupies until the video stops at the end. If yo are using the FLVPlayback component, set the autoRewind property to false.

  • Moving Audio Clip less then 1 frame in Premiere

    Is it possible to move an audio clip less then one frame in premiere CS4.  I recorded and then remixed in Audition 3.  Live concert was also recorded in HDV on a Canon hv30.  I want to use the remixed audio with the video footage in place of the camera audio.  It was recorded hdv 30P so one frame is a significant amount of time from the audios point of view.  The audio and video are about half a frame apart.  The only thing I can think of is take the audio back into audition and shorten the lead in by the required amount.  I was hoping for a easier way.
    Any thoughts would be greatly appreciated.
    Ken

    Ken,
    Glad that it did work for you. Now, there are still some frame-specific things that can and cannot be done, as PrPro is frame-based, but for your need, it sounded like a good solution.
    Thanks for reporting success,
    Hunt
    PS so you can mark your question as having been answered, right?

  • Firefox crashes upon attempting to print "Disqus" comments via "This frame" then "Print frame" route

    I once relied on Firefox to print enormous quantities of reader Disqus-generated comments on a host of different web sites, since Firefox handled the memory management requirements better than all other browsers I've used. In November of last year, however, I allowed myself be conned into upgrading Firefox, since which point EVERY attempt to print Disqus comments via the right click “This frame” then “Print frame” route has resulted in a Firefox crash—every one, haven't achieved a single success. I've upgraded the Adobe “Create pdf” add-on; deleted then re-installed the Adobe document print driver in the Windows control panel; upgraded Firefox again (today); retried the drill in safe mode; etc.—all with no effect. This is the link to the latest crash report: bp-a1a4a752-6d4c-418f-a90d-4a1f72150404. Attempting to print comments generated by programs other than Disqus seem to work fine.
    I mightily regret having been gulled into the original upgrade, since I effectively swapped a program that was working superbly for one that doesn't work at all. For whatever help you can provide, please accept my sincere thanks in advance.

    Guigs2, thanks for the response. Yes, I can save the content of the webpage, then copy to another program for printing, but the drill within FF was much easier & direct (of course). Do you expect a fix for the identified bug, or is this the end of the road? If/when there should ever be a fix, how will I know of it? Thanks again.

  • Document Class not work when I shift my MovieClip to 2nd Frame.

    Hello,
    All my content is at 1st frame of my FLA file...and I'm using Document Class... When I try to shift my content to 2nd frame, so I can use 1st frame for preloader.. but its not working...
    This is my document class... Basically at 1st frame I'm loading external jpg image to a MovieClip..
    Is it possible, I can **** my MovieClip and other content to 2nd frame of the timeline... ??? and Document Class work???
    Thanks...
    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";         
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;              
                   stage.addEventListener(Event.RESIZE, stageResize);         
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   pic.addChild(loader);    
              private function showImage(e:Event):void
                   try {                             
                        e.target.content.alpha = 1;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                   
                        e.target.content.smoothing = true;                             
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;              
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                   
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;         
                   bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);

    If you have code in your main class that references specific movieclips on the stage, they have to be on every frame you plan on using.
    If you have a movieclip named "pic" on frame 2, but you are referencing it right away in the main class, which starts on frame 1, then it is looking for a movieclip that does not exist until you move it to frame 2

  • Looping an animation twice then stop

    I have a banner that needs to play twice and then stop. Its 15 seconds and besides copying all the frames and pasting at the end to get this effect I want to do it with AS. Currently the animation is four mc's appearing at different frames in the main timeline. I figure using the if and else statements like if (should I create one movieclip for the entire animation and call it _mc_1) so if_mc_1 plays +++3 then stop?
    something to this effect.
    any help?
    thx
    rd

    Yes, using a flag variable is probably your best bet. At frame 1 you'd do something like:
    var loopCounter:int = 0;
    And then at the end of your animation, on frame n, you would do like:
    loopCounter++;
    if(loopCounter < 2){
         gotoAndPlay(2);
    You go to 2, because if you go to 1 you'll reset the variable.

  • Button on main timeline control movieclip

    Hello,
    I have a stop on my main timeline. At the stop I have a movieclip play. In the movieclip I will have a video play. After the video plays I have a button for the user to continue play until the end of the movieclip. Once the movieclip is done I want to resume back to a specific frame in my main timeline.
    I can't figure out how to make this work. Anyone have any ideas?
    Thanks in advance,
    Paul

    Ned,
    Thanks for the reply and the help.
    I actually got everything to work the way I need it to. I simply had my button in the movieclip continue play then at the end of the last frame, applied a little voodoo and I was all smiles after I tested my Movie. Here's what I did...
    x_btn in movieclip (not on main timeline) -
         x_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler10);
         function mouseDownHandler10(event:MouseEvent):void {
                  gotoAndPlay(41);
    last frame in movie clip -
         MovieClip(root).gotoAndStop(130);
    Paul

  • Need a clip to loop a few seconds then stop

    I am new to this stuff so play nice, please.
    I have a movieclip that has about 18 frames.
    On the last frame I have a script to goto and play at frame
    8.
    This works fine.
    What I need is to have it keep looping and then stop after
    like 10 seconds.
    so if someone could edit this code that would be great:
    gotoAndPlay(8);
    Thanks in advance to anyone who can help.

    Put this code in first frame of your animation.
    var a = 0;
    function time(){
    a++
    if(a == 10){
    stop();
    clearInterval(timeInterval);
    timeInterval = setInterval(time, 1000); // 1000 = 1 second
    I hope this help...

  • Accessing movieclips on different frames.

    Okay, So i have a gallery on my root timeline
    The gallery is called work_mc.  Inside of work_mc I have various buttons.  There is a different section on different frames.  For example,  ALL is on frame one, PRINT is on frame two, motion is on frame three.
    In the root here is the code:
    work_mc.urbanthmb_mc.addEventListener(MouseEvent.CLICK, clickHandler);
    work_mc.urbanthmb_mc.buttonMode = true;
    function clickHandler(event:MouseEvent):void {
        if (!workss_mc) {
            workss_mc = new mc_workss();
            workss_mc.addEventListener("closeButtonClick", onCloseClick);
            workss_mc.x = 225;
            workss_mc.y = 200;
    work_mc.gotoAndStop("urbanflats");
        addChild(workss_mc);
        removeChild(work_mc);
    function onCloseClick(e:Event):void {
        trace("clickedtrue");
        if (!work_mc) {
            work_mc = new mc_work();
            work_mc.x = 225;
            work_mc.y = 200;
        removeChild(workss_mc);
    addChild(work_mc);
    This is targeting the buttons that are on frame 1.  How do I get to the buttons that are on frame 3?  I tried just using the movieclip names but this doesnt seem to work?

    ahh, okay.  Just what I didn't want to hear ha.
    The thing is here is that I am removing and adding children for the root, once I get into frame 3 then I am in work_mc and I will have to do the same thing that I am doing on the root which is:
    var workss_mc:mc_workss;
    work_mc.urbanthmb_mc.addEventListener(MouseEvent.CLICK, clickHandler);
    work_mc.urbanthmb_mc.buttonMode = true;
    function clickHandler(event:MouseEvent):void {
        if (!workss_mc) {
            workss_mc = new mc_workss();
            workss_mc.addEventListener("closeButtonClick", onCloseClick);
            workss_mc.x = 225;
            workss_mc.y = 200;
    work_mc.gotoAndStop("urbanflats");
        addChild(workss_mc);
        removeChild(work_mc);
    function onCloseClick(e:Event):void {
        trace("clickedtrue");
        if (!work_mc) {
            work_mc = new mc_work();
            work_mc.x = 225;
            work_mc.y = 200;
        removeChild(workss_mc);
    addChild(work_mc);
    Then I am taking it to inside of work_mc since I have to work on frame 3
    Here is my code for that, but it doesn't seem to be working correctly
    var workss_mc:mc_workss;
    urbanthmb1_mc.addEventListener(MouseEvent.CLICK, clickHandlerurban);
    urbanthmb1_mc.buttonMode = true;
    function clickHandlerurban(event:MouseEvent):void {
         if (!workss_mc) {
            workss_mc = new mc_workss();
            workss_mc.addEventListener("closeButtonClick", onCloseClick);
            workss_mc.x = 225;
            workss_mc.y = 200;
    workss_mc = new mc_workss();
    this.gotoAndStop(1);
        addChild(workss_mc);
        this.parent.removeChild(this);
    function onCloseClick(e:Event):void {
        trace("clickedtrue");
        if (!this) {
            this.x = 225;
            this.y = 200;
        removeChild(workss_mc);
    addChild(this);
    When it does this, it is not removing work_mc OR this, it is just adding workss_mc..
    Any ideas?

  • Can I call timelines  across movieclips

    I have buttons in my main menu which load a movie and disable
    then re-enable when another button is pressed. Each button is
    actual a movieclip with a button embedded in it, then the mc is
    placed on the main timeline. I used global variables as indicators
    for the buttons to disable and enable. Here's some code I used on
    any one button;
    on (release) {
    if (_global.ButtonActiveArray[4] == false) {
    return;
    } else {
    gotoAndPlay(21);
    for (i=0; i<7; i++) {
    if (_global.ButtonActiveArray
    == false) {
    _root.button.gotoAndPlay(11);
    _global.ButtonActiveArray[0] = true;
    _global.ButtonActiveArray[1] = true;
    _global.ButtonActiveArray[2] = true;
    _global.ButtonActiveArray[3] = true;
    _global.ButtonActiveArray[5] = true;
    _global.ButtonActiveArray[6] = true;
    _global.ButtonActiveArray[4] = false;
    loadMovieNum("fashion-page.swf", 2);
    What's happening is when a button is disabled, its sent to
    frame 21 where is changes colour. When is re-enabled, it's still at
    21. So you have to rollOver it to get it back to it's active
    colour. I tried _root.button
    .gotoAndPlay(11) to send it to another frame but this doesn't
    work. Where am I going wrong?

    I have buttons in my main menu which load a movie and disable
    then re-enable when another button is pressed. Each button is
    actual a movieclip with a button embedded in it, then the mc is
    placed on the main timeline. I used global variables as indicators
    for the buttons to disable and enable. Here's some code I used on
    any one button;
    on (release) {
    if (_global.ButtonActiveArray[4] == false) {
    return;
    } else {
    gotoAndPlay(21);
    for (i=0; i<7; i++) {
    if (_global.ButtonActiveArray
    == false) {
    _root.button.gotoAndPlay(11);
    _global.ButtonActiveArray[0] = true;
    _global.ButtonActiveArray[1] = true;
    _global.ButtonActiveArray[2] = true;
    _global.ButtonActiveArray[3] = true;
    _global.ButtonActiveArray[5] = true;
    _global.ButtonActiveArray[6] = true;
    _global.ButtonActiveArray[4] = false;
    loadMovieNum("fashion-page.swf", 2);
    What's happening is when a button is disabled, its sent to
    frame 21 where is changes colour. When is re-enabled, it's still at
    21. So you have to rollOver it to get it back to it's active
    colour. I tried _root.button
    .gotoAndPlay(11) to send it to another frame but this doesn't
    work. Where am I going wrong?

  • Loop #  of times, stop at specific frame

    Hi there,
    I'm having trouble finding the answer to a simple (I hope)
    question. I made a flash banner and have successfully added an
    action that will loop it 3 times, stopping on the last frame. Here
    is the code I entered in a separate action layer:
    INSERTED A KEYFRAME IN FRAME 1:
    if (numberOfTimesToLoop<3) {
    gotoAndPlay(1);
    numberOfTimesToLoop++;
    } else {
    stop();
    INSERTED A KEYFRAME IN MY LAST FRAME OF THE TIMELINE:
    if (numberOfTimesToLoop<3) {
    gotoAndPlay(1);
    } else {
    stop();
    Works beautifully, only I need the movie to stop on frame 274
    on the last loop, where I want certain elements not to fade out (I
    have 279 frames in my movie). Can anyone help me out? I'd really
    appreciate it!

    I'm not sure I understand what code I'm supposed to put in
    frame 279 exactly.. There are two elements (on two separate layers)
    that need to stop at that frame on the 3rd loop.. I tried putting
    something like this on frame 279 of one of those layers:
    if (numberOfTimesToLoop=3) {
    stop();
    O so close.... but like with all code its either all right or all wrong.
    the 2 diffrent layers don't matter if your stoping the main timeline.
    go to frame 279 open up your ActionScript window and type in:
    if (numberOfTimesToLoop == 3) {
    stop();
    That is little guy is called a
    Comparison Operator
    http://flash-creations.com/notes/actionscript_operators.php  <==good site discribing them.
    Good luck and I hope it helps
    JT

Maybe you are looking for