3 Replies Latest reply on Apr 19, 2011 6:18 PM by Ned Murphy

    How to play XX amount of frames ONLY within a Move Clip?

    iliveudie12345

      EXAMPLE: I have a movie clip on the stage with 100 frames inside of it. If a hitTest == true, I want it to play a certain amount of frames depening on what the item is.

       

      I tried the following code:

       

      If(_root.char.hitTest(_root.blunt)==true){

           _root.highMeter.gotoAndPlay(currentFrame+5);

           trace("yes");

      }

       

       

      I get the trace to show YES. I can't get the MC to play 5 frames and 5 frames only!!! Any help?

        • 1. Re: How to play XX amount of frames ONLY within a Move Clip?
          Ned Murphy Adobe Community Professional & MVP

          You'll need to utilize something in the way of an enterFrame.  There are probably a few ways you could manage it, and one way would be to have the enterFrame function continually checking to see if you have reached the detsination frame.  So when you start you determine which frame will be the end frame based on the _currentframe+5 value, and then have the enterFrame stop when that frame is detected.  Something like the following would work...

           

          var stopFrame;

           

          if(char.hitTest(blunt)){
               stopFrame = highMeter._currentframe+5;
               highMeter.onEnterFrame = playToStopFrame;
          }

           

          function playToStopFrame(){
               highMeter.nextFrame();
               if(highMeter._currentframe == stopFrame){
                  delete highMeter.onEnterFrame;
               }
          }

           

          Note: I have removed all of the _root references figuring you have them there out of habit rather than necessity.

          • 2. Re: How to play XX amount of frames ONLY within a Move Clip?
            iliveudie12345 Level 1

            I already have an enter Frame function.

             

            On the main timeline, I am using the

             

            function enterFrame (){

                 CODE

            }

             

            How can I just implement the playing 5 frames at a time into what I have? Is it possible? Or do I have to redo the code layout to how you suggested.

            • 3. Re: How to play XX amount of frames ONLY within a Move Clip?
              Ned Murphy Adobe Community Professional & MVP

              I have no idea if your enterFrame function can be used since it contains nothing from which I can make a determination.  If you study the code I provided you may be able to implement it in whatever CODE you have.

              1 person found this helpful