4 Replies Latest reply on Jul 21, 2011 8:42 AM by Owen_Alextoys

    Go to next frame

    Owen_Alextoys

      Hi,

       

           I have a FLA that was originally created in indesign and I'm trying to get it to go to the next frame at a set interval. This is my first attempt at action script This is what I've come up with but it's not working. any help would be much apreciated

       

      stop();

      var myTimer:Timer = new Timer(5000);

      myTimer.addEventListener(TimerEvent.TIMER, fiveSec);

      myTimer.start();

       

      function fiveSec(event:TimerEvent):void

      {

         this.nextFrame();

      }

        • 1. Re: Go to next frame
          Ned Murphy Adobe Community Professional & MVP

          There's nothing wrong with the code.  Do you have enough frames in the timeline to go anywhere?  Try putting a trace in the function to see what it has to say about which frame you're in...

           

          function fiveSec(event:TimerEvent):void

          {
             this.nextFrame();

             trace(currentFrame);

          }

          • 2. Re: Go to next frame
            Owen_Alextoys Level 1

            I have three frames in the timeline.

             

            I got the following error when I tired to debug

             

            Scene 1, Layer 'Actions', Frame 1, Line 16 1021: Duplicate function definition.

            Here's the AS3 for that frame.

             

            /* Stop at This Frame

            The Flash timeline will stop/pause at the frame where you insert this code.

            Can also be used to stop/pause the timeline of movieclips.

            */

             

            stop();

            var myTimer:Timer = new Timer(5000);

            myTimer.addEventListener(TimerEvent.TIMER, fiveSec);

            myTimer.start();

             

            function fiveSec(event:TimerEvent):void

            {

               this.nextFrame();

            }

            function fiveSec(event:TimerEvent):void

            {

               this.nextFrame();

               trace(currentFrame);

            }

            • 3. Re: Go to next frame
              Ned Murphy Adobe Community Professional & MVP

              You cannot have two functions with the same name.  You only needed to add the trace line to the existing function.

              • 4. Re: Go to next frame
                Owen_Alextoys Level 1

                Perfect that fixed it. Thanks for the help. This is my first project with action script.