1 Reply Latest reply on Jun 16, 2010 1:50 AM by Devendran

    Adding two more Star Trails in movie clip

    xcmuddman

      Hi All,

       

      I bought a flash file the other day which i plan to modify and use for an intro to a project i am working on. Currently there is one instance of a Star which follows a path and emits "sparkles" while tracing the path. I would like to add two more stars/ paths. I tried modifying some of the code, and am working through it, but wanted to know if anyone could help me out a bit.

       

      thanks!

       

      Patrick

       

       

      import flash.filters.*;

       

       

      //--------------variables to change--------------------------//

       

      //modify the size of the sparkles

      var maxSparkSize:Number = 25;

      var minSparkSize:Number = 8;

      //set the speed the sparkles fade, 0 is never fade,the higher number quicker the fade

      var fadeSpeed:Number = 1//5;

      //speed which the sparkles fall, 0 is no fall, the higher the number the quicker the fall

      var fallSpeed:Number = 0.5;

      //the speed which the particles drift sideways. 0 gives no drift, positive numbers give right drift

      // negative numbers give left drift

      var windSpeed:Number = 0;

      //change the colour

      var randomColour:Boolean = true;

      defaultColour = 0xFFcc00;

      // the path to the followe_mc

      path = this.holder_mc.follower_mc;

      path = this.holder2_mc.follower2_mc;

       

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

       

      //you do not need to modify the code below here...

      var sparkle:Number = 0;

      var mousePosX:Number;

      var mousePosY:Number;

      var whichBat:Number;

      var count:Number = 0;

       

      this.createEmptyMovieClip("empty",this.getNextHighestDepth());

      //make the shape on top of the sparkles

      path.shape_mc.swapDepths(1000);

       

      startSparkles();

       

      function startSparkles() {

       

                  this.onEnterFrame = function() {

                              var pathX:Number = path._x;

                              var pathY:Number = path._y;

                             

                              xPos = randRange(pathX-2, pathX+2);

                              yPos = randRange(pathY-2, pathY+2);

                              createSparkle(xPos,yPos);

                             

                  };

      }

       

      function createSparkle(xPos, yPos) {

                  movingSparkle = this.attachMovie("colouredSparkle", "s_"+sparkle, sparkle+10);

                  movingSparkle2 = this.attachMovie("colouredSparkle", "ss_"+sparkle, sparkle+101);

                  sparkle++;

                 

                              if(sparkle>100){

                              sparkle = 0;

                  }

                  setParams(movingSparkle);

                  setParams(movingSparkle2);

                 

      }

      function setParams(movingSparkle){

                  //position the sparkle

                  movingSparkle._x = xPos;

                  movingSparkle._y = yPos;

                  //set initial size

                  movingSparkle._xscale = movingSparkle._yscale=Math.random()*maxSparkSize+minSparkSize;

                  movingSparkle._rotation = randRange(0, 360);

       

                  if (randomColour == true) {

                              col = Math.round(Math.random()*0xFFFFFF);

       

                  } else {

                              col = defaultColour;

                  }

       

                  colouredFill = new Color(movingSparkle.colour_mc);

                  colouredFill.setRGB(col);

                  colouredFill = new Color(movingSparkle.white_mc);

                  colouredFill.setRGB(col);

       

       

                  moveSparkle(movingSparkle);

      }

       

      function moveSparkle(movingSparkle) {

                  var rot = randRange(-15, 15);

                  var blurX = randRange(1, 5);

                  var blurY = blurX;

                  var blurFilter = new BlurFilter(blurX, blurY, 3);

                  //add some blur to the sparkle to make it softer

                  movingSparkle.white_mc.filters = [blurFilter];

                  //calculate the amount the sparkle will fade

                  var alphaDrop = randRange(1, fadeSpeed);

                  //commit the movements...

                  //this onEnterFrame moves the spark, rotates it, scales it and fades it.

                  movingSparkle.onEnterFrame = function() {

                              //change speed

                              this._y += fallSpeed;

                              this._x += windSpeed;

                              //change rotation

                              this._rotation = this._rotation+rot;

                              //make it smaller

                              this._xscale = this._yscale=this._xscale*0.98;

                              //fade the sparkle

                              this._alpha = this._alpha-alphaDrop;

                              //remove the movieclip if it get tiny

                              if (this._alpha<10) {

                                          this.removeMovieClip();

                              }

                              if (this._height<4) {

                                          this.removeMovieClip();

                              }

       

                  };

       

      }

       

       

      function setColour(mc, col) {

                  colourIt = new Color(mc);

                  colourIt.setRGB(col);

      }

       

      function randRange(min:Number, max:Number):Number {

                  var randomNum:Number = (Math.random()*(max-min))+min;

                  return randomNum;

      }