5 Replies Latest reply on May 14, 2008 11:46 AM by kglad

    alpha fade solution?

    greenjerk
      Hi,

      I have some actionscript that creates a vine and when it hits the document edge it creates another, and another and another.

      I've been digging and digging but cannot figure out how to decrease the alpha per frame on the successive vines and then stop the vine creation after 10.

      Here's what i have:

      x = 550; //starting points
      y = 250;
      angle = -3;
      v = 0;
      len = 5;
      points = [];
      lineStyle(2, (Math.random() * 25) << 8, 100);
      moveTo(x, y);
      count = 0;
      onEnterFrame = function () {
      x = x + (Math.cos(angle) * len);
      y = y + (Math.sin(angle) * len);
      if (Math.random() > 0.8) {
      leaf = attachMovie("leaf", "leaf" + count, count++, {_x:x, _y:y, _rotation:(((angle * 180) / Math.PI) + (Math.random() * 80)) - 40});
      leaf.scale = 50 + (Math.random() * 100);
      leaf._xscale = (leaf._yscale = 0);
      leaf.onEnterFrame = function () {
      this._xscale = this._xscale + 2;
      this._yscale = this._yscale + 2;
      if (this._xscale > this.scale) {
      delete this.onEnterFrame;
      }
      };
      col = new Color (leaf);
      col.setRGB((Math.random() * 25) << 8);
      }
      points.push({x:x, y:y, angle:angle});
      v = v + ((Math.random() * 0.08) - 0.04);
      v = v * 0.93;
      angle = angle + v;
      lineTo(x, y);
      if ((((x > 780) || (x < 0)) || (y > 580)) || (y < 0)) { // bound limits for vine generation
      index = Math.floor(Math.random() * points.length);
      x = points[index].x;
      y = points[index].y;
      moveTo(x, y);
      angle = points[index].angle;
      lineStyle(1, (Math.random() * 25) << 8, 100);
      }
      };

      thanks in advance