0 Replies Latest reply on Jul 6, 2008 8:01 PM by JCREACH

    falling leaves

    JCREACH
      I have created a simple "falling leaves" animation including five different leaf movieclips. I am trying to figure out how to make them randomly turn over as they fall. Any suggestions?

      Here is what I have on each movie clip:

      onClipEvent (load) {
      // specifies the size of the movie stage
      movieWidth = 800;
      movieHeight = 600;
      // variables that will modify the falling leaves
      i = 1+Math.random()*2;
      k = -Math.PI+Math.random()*Math.PI;
      // giving each leaf unique characteristics
      this._xscale = this._yscale=50+Math.random()*100;
      this._rotation = this._rotation=Math.random()*300;
      this._alpha = 100+Math.random()*100;
      this._x = -15+Math.random()*movieWidth;
      this._y = -15+Math.random()*movieHeight;
      }
      onClipEvent (enterFrame) {
      // putting it all together
      rad += (k/180)*Math.PI;
      this._x -= Math.cos(rad);
      this._y += i;
      if (this._y>=movieHeight) {
      this._y = -5;
      }
      if ((this._x>=movieWidth) || (this._x<=0)) {
      this._x = -10+Math.random()*movieWidth;
      this._y = -5;
      }
      }