In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

leafs ...

Get Adobe Flash player
by shin10 25 Oct 2012
    Embed
package {
    import flash.display.Sprite;
    import flash.events.Event;
    public class Main extends Sprite {
        public var leafs:Array = [];
        public function Main() {
           for(var i:int = 0; i < 300; i++){
                 leafs.push(addChild(new Leaf()));           
            }
            addEventListener(Event.ENTER_FRAME, loop);
        }
        public function loop(e:Event=null):void{
            for each(var l:Leaf in leafs){
                if(Math.random()<0.02)l.chaos();
                l.y += l.g;  
                if(l.y>1000){
                    l.reset();
                }else{
                    l.x += l.vx;        
                    l.z += l.vz;        
                    l.rX += l.rvx;        
                    l.rY += l.rvy*= .99995;        
                    l.ampl *= .997;        
                    l.rotationX = Math.sin(l.rX)*l.ampl;        
                    l.rotationY = l.rY;        
                    l.leaf.rotationY += l.lrY;
                }
            }
            leafs = leafs.sortOn("z", Array.NUMERIC);
            for each(l in leafs){setChildIndex(l, 0)};
        }
    }
}
import flash.display.Sprite;
class Leaf extends Sprite{
    public var leaf:Sprite = new Sprite();
    public var ampl:Number;
    public var vx:Number;
    public var vz:Number;
    public var rvx:Number;
    public var rvy:Number;
    public var g:Number;
    public var rX:Number;
    public var rY:Number;
    public var lrY:Number;
    public function Leaf(){
        leaf.graphics.beginFill((Math.random()*0xFFFF)<<8,1);
        leaf.graphics.lineStyle(1,0);
        leaf.graphics.moveTo(-75,0);
        leaf.graphics.lineTo(50,0);
        leaf.graphics.curveTo(-25, 20,-50,0);
        leaf.graphics.curveTo(-25,-20, 50,0);
        leaf.graphics.lineTo(-75,0);
        leaf.graphics.endFill();
        leaf.y = 300;
        leaf.rotationX = 90;
        addChild(leaf);
        reset();
        y = Math.random()*-2000-1000;
    }
    public function reset():void{
        x = 500*Math.random();
        y = -1000;
        z = 1000*Math.random();
        ampl = 80;
        rX = Math.random();
        rY = 0.01;
        chaos();
    }
    public function chaos():void{
        ampl *= 1+(Math.random()-.5)*.1; 
        vx = 25*(Math.random()-.5);
        vz = 25*(Math.random()-.5);
        rvx = .1 + .1*Math.random();
        rvy = .1 + .5*Math.random();
        g = 2 + 2*Math.random();
        lrY = 25*(Math.random()-.5);
    }
}