3 Replies Latest reply on May 4, 2015 6:45 AM by sotirisv77862423

    Next frame problem

    sotirisv77862423

      btn2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

       

       

      function fl_ClickToGoToNextFrame(event:MouseEvent):void

      {

        nextFrame();

      }

       

       

      /* Click to Go to Previous Frame and Stop

      Clicking on the specified symbol instance moves the playhead to the previous frame and stops the movie.

      */

       

       

      btn1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);

       

       

      function fl_ClickToGoToPreviousFrame(event:MouseEvent):void

      {

        prevFrame();

      }

       

       

      I write this code and when go to last frame then move me to other scene. I want when go to last frame and i click the button again to move me to first frame to same scene. What is the problem?

        • 1. Re: Next frame problem
          Ned Murphy Adobe Community Professional & MVP

          You show code for two buttons.  Since you say you "click the button again", I assume that means you are clicking the same nextFrame() button, so it will advance to the next scene if you have one.

           

          If you happen to have the same button in the last frame but assign it a different name (btn1) then you should put that button on a different layer because it will inherit the btn2 name due to being in an adjacent frame and will execute the btn2 code.

          • 2. Re: Next frame problem
            Nipun Asthana Adobe Employee

            This should do it for you!

             

            stop();

            btn2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

             

            function fl_ClickToGoToNextFrame(event: MouseEvent): void {

              if (currentFrame < totalFrames)

              gotoAndStop(currentFrame + 1);

              else

              gotoAndStop(1);

            }

             

            /* Click to Go to Previous Frame and Stop

            Clicking on the specified symbol instance moves the playhead to the previous frame and stops the movie.

            */

             

            btn1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);

             

            function fl_ClickToGoToPreviousFrame(event: MouseEvent): void {

              if (currentFrame > 1)

              gotoAndStop(currentFrame - 1);

              else

              gotoAndStop(totalFrames);

            }

            • 3. Re: Next frame problem
              sotirisv77862423 Level 1

              Thank you.