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

code on 2008-12-17

Get Adobe Flash player
by szktkhr 17 Dec 2008
    Embed
package {
	import flash.display.*;
	public class Main extends Sprite {
			
		public function Main() {
			for (var i:uint = 300; i-- > 0;) {
				addChild(new BrownMovement(2, 4));
			}
		}
		
	}
	
}

import flash.display.*;
import flash.geom.Point;
import flash.events.*;
class BrownMovement extends Sprite {
	private var radius:Number;
	private var speed:Number;
	
	public function BrownMovement(radius:Number = 1, speed:Number = 10) {
		this.radius = radius;
		this.speed = speed;
		addEventListener(Event.ADDED_TO_STAGE, initialize);
		addEventListener(Event.REMOVED_FROM_STAGE, uninitialize);
	}
	
	private function initialize(event:Event):void {
		graphics.beginFill(0x000000);
		graphics.drawCircle(0, 0, radius);
		graphics.endFill();
		x = Math.random() * stage.stageWidth;
		y = Math.random() * stage.stageHeight;
		addEventListener(Event.ENTER_FRAME, crusing);
	}
	
	private function uninitialize(event:Event):void {
		addEventListener(Event.ADDED_TO_STAGE, initialize);
		addEventListener(Event.REMOVED_FROM_STAGE, uninitialize);
		addEventListener(Event.ENTER_FRAME, crusing);
	}
	
	private function crusing(event:Event):void {
		x += Math.random() * 2 > 1? (Math.random() * speed): -(Math.random() * speed);
		y += Math.random() * 2 > 1? (Math.random() * speed): -(Math.random() * speed);
		if (x > stage.stageWidth) x = stage.stageWidth / 2;
		if (y > stage.stageHeight) y = stage.stageHeight / 2;
	}
}