6 Replies Latest reply on Dec 6, 2011 4:37 AM by robdillon

    Goto a new frame and stop the current movie clip?

    media kat Level 1

      In cs5.5, I have a frame with a movie clip on it. When a user clicks a button, I want the movie clip to stop and the user to be directed to another frame. It is correctly redirecting to a different frame, however, the movie clip is still on the stage and playing. How can I modify the following code to make it not just go to a different frame, but also stop the movie clip that is on that frame from playing?

       

      btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

       

       

      function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

      {

                gotoAndStop(10);

      }

        • 1. Re: Goto a new frame and stop the current movie clip?
          robdillon Most Valuable Participant

          btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

           

           

          function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

          {

                    movieClipInstanceName.stop();

                    gotoAndStop(10);

          }

           

          Change movieClipInstanceName to the actual name of the movieClip that you want to stop.

          1 person found this helpful
          • 2. Re: Goto a new frame and stop the current movie clip?
            media kat Level 1

            So would I add this code to each button that a user might click on to make sure that the movie clip stops regardless of which button is clicked on?

             

            Thanks!

            • 4. Re: Goto a new frame and stop the current movie clip?
              media kat Level 1

              That worked, it stopped the movie clip, however, the movie clip still shows on other frames. How do I modify the code to not only stop the movie clip but to make it disappear on the other frames?

               

              Thanks!

               

              btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

               

               

              function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

              {

                        movieClipInstanceName.stop();

                        gotoAndStop(10);

              }

              • 5. Re: Goto a new frame and stop the current movie clip?
                iFlashAppsToo Level 3

                btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

                 

                 

                function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

                {

                          movieClipInstanceName.stop();

                          movieClipInstanceName.visible = false;

                          gotoAndStop(10);

                }

                 

                 

                //---

                 

                to be more efficient if you have many buttons doing the same thing:

                 

                btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

                 

                function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

                {

                          doSomething();

                          gotoAndStop(10);

                }

                 

                function doSomething()

                {

                          movieClipInstanceName.stop();

                          movieClipInstanceName.visible = false;

                          //do something else

                }

                • 6. Re: Goto a new frame and stop the current movie clip?
                  robdillon Most Valuable Participant

                  How you make a movieClip leave the stage will depend on how it got there in the first place and whether or not you need to use it again. For instance, if you are using the timeline and you have a movieClip on frame 1 and you want to use that movieClip throughout the whole movie, then you can just leave it in the timeline. If you want that movieClip to work and be available in frames 1 through 100, but not in frames 101 through 200, and again in frames 201 through 300, you can create a key frame at frame 101 and 201 for that movieClip. Then you can move the movieClip off the visible area of the stage at frame 101.

                   

                  If you don't need the movieClip after frame 100 and you won't be going back to the area of the timeline before frame 100, you can just put an empty key frame at frame 101 and the movieClip won't show from frame 101 on.