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 Version MSMS

Snow.as
Get Adobe Flash player
by kadal 06 Apr 2009
    Embed
// forked from kadal's Snow
/* Snow.as */
package {
    
	import flash.display.Sprite;
	import flash.display.Graphics;
	import flash.display.DisplayObject;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.events.Event;
	import flash.filters.BlurFilter;

        [SWF(backgroundColor="#000000", frameRate=30)]
        
	public class Snow extends Sprite {
		public function Snow() {
			var timer:Timer = new Timer(20, 0);
			timer.addEventListener(TimerEvent.TIMER, myCircle);
			timer.start();
		}

		private function myCircle(evt:TimerEvent):void {
			var p:Sprite = new Sprite();
			p.graphics.beginFill(0xFFFFFF);
			p.graphics.drawCircle(0, 0, 10);
			p.x = Math.random() * stage.stageWidth;
			p.y = Math.random() * stage.stageHeight;
			p.graphics.endFill();

			var filters_array:Array = new Array();
			var myBlur:BlurFilter = new BlurFilter(5, 5, 1);
			filters_array.push(myBlur);
			p.filters = filters_array;
                        p.alpha = 0.1;

			addChild(p);
			p.addEventListener(Event.ENTER_FRAME, smaller);
		}

		private function smaller(evt:Event):void{
			var p:Object = evt.target;
			p.scaleX *= 0.96;
			p.scaleY *= 0.96;
			p.alpha = 1 - p.scaleX*0.9 + 0.1;
			p.x += ((stage.stageWidth/2)-p.x)/500;
			p.y += ((stage.stageHeight/2)-p.y)/500;
			if(p.width < 1){
				p.visible = false;
				p.removeEventListener(Event.ENTER_FRAME, smaller);
				removeChild(DisplayObject(p));
			}
		}
	}
}