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

Snow Flakes

Get Adobe Flash player
by Redshift 01 Apr 2009
package{
    import flash.display.*;
    import flash.events.*;
    [SWF(width=450, height=450, backgroundColor=0x000000, frameRate=36)]
    public class Snow extends MovieClip{
        public static var windowHeight:Number;
        public static var windowWidth:Number
        public var count:int = 1000;
        public var references:Array = new Array(count);
        
        public function Snow():void{
            windowHeight = stage.stageHeight;
            windowWidth = stage.stageWidth;
            for(var i:int = 0; i < count; i++){
                references[i] = new MovieClip();
                references[i].graphics.beginFill(0xFFFFFF);
                references[i].graphics.drawCircle(0, 0, 2);
                references[i].init = function():void{
                    this.x = Math.random()*windowWidth;
                    this.alpha = Math.random()*0.5+0.5;
                    this.scaleX = this.scaleY = this.alpha;
                    this.speed = this.alpha*4;
                    this.sinInc =(Math.random()-0.5)*0.118;
                    this.sinFloat = 0;
                    this.y = -(Math.random()*windowHeight);
                }
                    references[i].init();
                addChild(references[i]);
            }
            addEventListener(Event.ENTER_FRAME, frame);
        }

	public function frame(e:Event):void{
            for(var i:int = 0; i < count; i++){
                update(references[i])
            }
	}
	public function update(ref:MovieClip):void{
            ref.sinFloat += ref.sinInc
	    ref.x += Math.sin(ref.sinFloat)*0.5;
	    ref.y += ref.speed;
			
	    if(ref.y > windowHeight){
                ref.init();
		ref.y = -4;
	    }
        }
    }
}