3 Replies Latest reply on Jun 9, 2009 10:37 AM by kglad

    how to start and stop looping

    Tiffany Eubanks

      I'm very new to Flash / action script, so I just need to know where to put both the start loop, and the end loop code (below) in my Flash file to make the waving effect on this flag (link below) start and stop when I need it to, because I'm adding a small amount of flash both before and after it. thanks.....

       

      loopI = setInterval(loopF,40);

       

      to start the waving and use:

       

      clearInterval(loopI);

       

      to stop the waving.

       

      function loopF(){
         
          // move the matrix by speed along x to shift the noise
          shift.translate(speed, 0);
         
          // drawing in the perlin movie clip,
          // create a rectangle with the perlin noise
          // drawn in it with an offset supplied by the
          // shift matrix
          with (displace_mc.perlin){
              clear();
              beginBitmapFill(noiseBitmap, shift);
              moveTo(0,0);
              lineTo(ramp._width, 0);
              lineTo(ramp._width, ramp._height);
              lineTo(0, ramp._height);
              lineTo(0, 0);
              endFill();
          }
         
          // draw the displacement movie clip in the
          // displaceBitmap (used in displaceFilter)
          displaceBitmap.draw(displace_mc);
          // apply displaceFilter to the flag
          flag_mc.filters = [displaceFilter];

      updateAfterEvent();
      }

       

       

      http://www.senocular.com/flash/source.php?id=0.188

        • 1. Re: how to start and stop looping
          kglad Adobe Community Professional & MVP

          i told you and it's in your message:

           

          use:

           

          loopI = setInterval(loopF,40);

           

          to start the waving.

           

           

          use:

           

          clearInterval(loopI);

           

          to stop the waving.

           

           

          // do not edit the below code:

           

          function loopF(){
             
              // move the matrix by speed along x to shift the noise
              shift.translate(speed, 0);
             
              // drawing in the perlin movie clip,
              // create a rectangle with the perlin noise
              // drawn in it with an offset supplied by the
              // shift matrix
              with (displace_mc.perlin){
                  clear();
                  beginBitmapFill(noiseBitmap, shift);
                  moveTo(0,0);
                  lineTo(ramp._width, 0);
                  lineTo(ramp._width, ramp._height);
                  lineTo(0, ramp._height);
                  lineTo(0, 0);
                  endFill();
              }
             
              // draw the displacement movie clip in the
              // displaceBitmap (used in displaceFilter)
              displaceBitmap.draw(displace_mc);
              // apply displaceFilter to the flag
              flag_mc.filters = [displaceFilter];

          updateAfterEvent();
          }

           

           

          http://www.senocular.com/flash/source.php?id=0.188

          • 2. Re: how to start and stop looping
            Tiffany Eubanks Level 1

            Yes, I see that you put that in the original post, however I'm very new to flash as I explained and simply need to know where specifically to put the start / stop code.

            • 3. Re: how to start and stop looping
              kglad Adobe Community Professional & MVP

              you put that wherever you want to start and stop the loop.

               

              for example, if you have button that when pressed should start the loop, then put that start-loop code in the button handler.