5 Replies Latest reply on Oct 24, 2009 8:59 AM by kglad

    Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???

    codeoverride1980

      I have an animation script for particles that was created in Flash 6. I'm trying to recreate it in my flash document that is setup as Flash 8. I couldn't get the animation to play and then I figured out that if I go back to this original Flash 6 document and change it to Flash 8, it won't play in that document either.

       

      I'm really new to Flash and scripting in general. Is there a solution that preferably involves changing the Flash 6 particles effect document so that I can recreate it in my Flash 8 document and have it animate?

       

      I attached the file but here is the script anyway..

       

      This is the script in the timeline:

       

      c=0;
      totalParticles = 100;
      while (c<totalParticles) {
      c++;
      duplicateMovieClip("particle0","particle"+c,c);
      }

       

      And this is the script in the movie object:

       

      onClipEvent (enterFrame) {
      r++;
      yvel+=(yvel2-yvel)/10;
      xvel+=(xvel2-xvel)/10;
      if (r==quant) {
      quant=minVal+random(rnd);
      r=0;
      yvel2=random((rvel*2)+1)-rvel;
      xvel2=random((rvel*2)+1)-rvel;
      }
      _x+=xvel;
      _y+=yvel;
      }
      onClipEvent (load) {
      _xscale = _yscale = 10 + random(50);
      _x = random(Stage.width);
      _y = random(Stage.width);
      minVal=25;
      rnd=25;
      quant=minVal+random(rnd);
      rvel = 1;
      yvel2=random((rvel*2)+1)-rvel;
      xvel2=random((rvel*2)+1)-rvel;
      }

       

      Thanks!

        • 1. Re: Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???
          kglad Adobe Community Professional & MVP

          the first error is not initializing r.  try:

           


           

          c=0;
          totalParticles = 100;
          while (c<totalParticles) {
          c++;
          duplicateMovieClip("particle0","particle"+c,c);
          }

           

          And this is the script in the movie object:

           

          onClipEvent (enterFrame) {
          r++;
          yvel+=(yvel2-yvel)/10;
          xvel+=(xvel2-xvel)/10;
          if (r==quant) {
          quant=minVal+random(rnd);
          r=0;
          yvel2=random((rvel*2)+1)-rvel;
          xvel2=random((rvel*2)+1)-rvel;
          }
          _x+=xvel;
          _y+=yvel;
          }
          onClipEvent (load) {

          r=0;

          _xscale = _yscale = 10 + random(50);
          _x = random(Stage.width);
          _y = random(Stage.width);
          minVal=25;
          rnd=25;
          quant=minVal+random(rnd);
          rvel = 1;
          yvel2=random((rvel*2)+1)-rvel;
          xvel2=random((rvel*2)+1)-rvel;
          }

           

          Thanks!

          • 2. Re: Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???
            codeoverride1980 Level 1

            Thanks for the reply! I really appreciate you taking the time to help out because I've spent hours on it and can't seem to figure it out

            I tried the script that you corrected but it still won't animate. The file that I attached plays fine until I change it to Flash 8. Any more ideas?

            • 3. Re: Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???
              kglad Adobe Community Professional & MVP

              the next two errors are failures to initialize xvel and yvel.  use:

               


               


               

              c=0;
              totalParticles = 100;
              while (c<totalParticles) {
              c++;
              duplicateMovieClip("particle0","particle"+c,c);
              }

               

              And this is the script in the movie object:

               

              onClipEvent (enterFrame) {
              r++;
              yvel+=(yvel2-yvel)/10;
              xvel+=(xvel2-xvel)/10;
              if (r==quant) {
              quant=minVal+random(rnd);
              r=0;
              yvel2=random((rvel*2)+1)-rvel;
              xvel2=random((rvel*2)+1)-rvel;
              }
              _x+=xvel;
              _y+=yvel;
              }
              onClipEvent (load) {

              r=0;

              xvel=0;

              yvel=0;

              _xscale = _yscale = 10 + random(50);
              _x = random(Stage.width);
              _y = random(Stage.width);
              minVal=25;
              rnd=25;
              quant=minVal+random(rnd);
              rvel = 1;
              yvel2=random((rvel*2)+1)-rvel;
              xvel2=random((rvel*2)+1)-rvel;
              }

               

              Thanks!

              • 4. Re: Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???
                codeoverride1980 Level 1

                That did it!!! Thank you SO much!

                 

                Just one more thing.. I made a rectangle movie clip on the stage and put the particle along with the code inside it. How can I keep the particles inside this rectangle movie clip?

                 

                I tried to change these lines:

                _x = random(Stage.width);

                _y = random(Stage.width);

                 

                to

                 

                _x = random(dust_movie.width);

                _y = random(dust_movie.height);

                 

                to see if it stays contained and although it looked better, they still seem to exit the area and are not really filling it evenly.. seems off centered to the left. Am I doing something wrong? Thanks again

                • 5. Re: Animation freezes (I think because the script is Flash 6 and my doc is CS3) ???
                  kglad Adobe Community Professional & MVP

                  give your rectangle and instance name, say rectangle.  you can then use:

                   

                  onClipEvent (enterFrame) {
                      if(_x<xmin||_x>xmax){
                          xvel*=-1;
                          _x+=xvel;
                      }
                      if(_y<ymin||_y>ymax){
                          yvel*=-1;
                          _y+=yvel;
                      }
                      _x += xvel;
                      _y += yvel;
                  }
                  onClipEvent (load) {
                      xmin=_parent.rectangle._x;
                      xmax=xmin+_parent.rectangle._width

                   

                      ymin=_parent.rectangle._y;
                      ymax=ymin+_parent.rectangle._height;

                   

                      xvel = (.5-Math.random())*4;
                      yvel = (.5-Math.random())*4;
                     
                      _xscale = _yscale=10+random(50);
                      _x = xmin+Math.random()*(xmax-xmin);
                      _y = ymin+Math.random()*(ymax-ymin);
                  }

                  1 person found this helpful