Skip navigation
Usagi_Bomb
Currently Being Moderated

Help with animation and buttons

Jan 20, 2014 7:28 AM

Tags: #action_script_3 #actions #animation_repeat

So I have a small issue. I have an animation that is set to stop when I open the swf. A play button is ther and works fine, When I hit it it plays through the animation, but stops once it's done. I need the animation to loopback to the begining. Can anyone help me out?

 
Replies
  • Currently Being Moderated
    Jan 20, 2014 7:57 AM   in reply to Usagi_Bomb

    Wondering where loop

     

    this.gotoAndPlay(1)

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 20, 2014 8:04 AM   in reply to Usagi_Bomb

    If you have a bunch of code on the first frame that sets anything up you might not want to return back to the first frame in your loop. Only you know what you have for code on the first frame to answer that. If that's the case then on the last frame of the animation just skip the first frame by telling it to go back to frame 2 to loop.

     

    On the last frame:

     

    gotoAndPlay(2);

     

    If you wish to repeat frame 1 then put your stop() in a condition. Something like this:

     

    if (loop == null)

    {

         // first time running (var loop doesn't exist)

     

         // define the var so it will exist next time

         var loop:Boolean = true;

     

         // stop initially

         stop();

    }

     

    The next time the animation returns to frame 1 the variable 'loop' will exist and the stop() will be ignored, continuing the playhead (looping).

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 22, 2014 7:47 AM   in reply to Usagi_Bomb

    You're welcome and good luck!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points