1 Reply Latest reply on Sep 7, 2009 4:53 PM by kglad

    Stopping a movie generating shapes

    bigowen23

      Hi.  I'm hoping someone can help me stop this.  Any help getting this thing woring would be much appreciated.  The code comes from this site:

       

      http://www.pixelhivedesign.com/tutorials/Realistic+Flash+Smoke+Effect/

       

      He creates a movieclip called aPuff and then gives the movieclip an identifier of aPuff as well.  It generates a smoke-like effect which is really nice; however, I'm wanting to get it to stop at some point...preferrably by allowing the last puff to go up and fade out.

       

      How can I accomplish that?

       

      Thanks again.

       

      // ------------------------------------------------

      // Realistic Smoke Effect - www.pixelhivedesign.com

      // ------------------------------------------------

      fadeSpeed = 1;    // Smoke fade speed.

      floatUpSpeed = 2; // Smoke float up speed.

      // Every frame attach a puff of smoke.

      this.onEnterFrame = function(){

        // Get next available depth.

        d = this.getNextHighestDepth();

        // Attach a puff of smoke.

        aPuff = attachMovie('aPuff','aPuff'+d,d);

        // Set initial scale to 10%.

        aPuff._xscale = aPuff._yscale = 10;

        // Put puff where the mouse is. (add small random)

        aPuff._x = Math.random() * 5;

        // Randomizes the starting animation for realism.

        aPuff.gotoAndPlay(Math.round(Math.random()*20));

        // Smoke will animate each frame.

        aPuff.onEnterFrame = function(){

          // Scale smoke up.

          this._xscale = this._yscale += fadeSpeed;

          // Fade smoke.

          this._alpha -= fadeSpeed;

          // Smoke floating up.

          this._y  -= floatUpSpeed;

          // When smoke is 100% scale, remove it.

          if(this._xscale >= 100){

            this.removeMovieClip();

          }

        }

      }