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

flash on 2010-5-31

Get Adobe Flash player
by plus-tic 30 May 2010
/**
 * Copyright plus-tic ( http://wonderfl.net/user/plus-tic )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eOuZ
 */

package
{
	import flash.display.Sprite;
	import flash.events.Event;
 
	public class Main extends Sprite
	{
		private var balls:Vector.<Ball> = new Vector.<Ball>();
		private var count:int = 0;
 
		public function Main()
		{
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
 
		private function onEnterFrame(event:Event):void 
		{
			if (count++ % 1 == 0)
			{
				var ball:Ball = new Ball();
				addChild(ball);
				balls.push(ball);
			}
 
			for (var i:int = 0; i < balls.length; i++)
			{
				balls[i].move();
				if (balls[i].alpha < 0.1)
				{
					removeChild(balls[i]);
					balls.splice(i--, 1);
				}
			}
		}
	}
}
 
import flash.display.Sprite;
 
class Ball extends Sprite
{
	public var vx:int = Math.random() * 20 - 10;
	public var vy:int = -(20 + Math.random() * 20);
	public var vz:int = Math.random() * 20 - 10;
	public const RADIUS:int = 15;
	
	public function rand(num:Number):Number{
		return Math.random()*num;
	}
 
	public function Ball()
	{
		this.x = 465 / 2;
		this.y = 465;
		this.z = 600;
 
		graphics.beginFill(rand(0xffffff));
		graphics.drawCircle(0, 0, rand(RADIUS));
		graphics.endFill();
	}
 
	public function move():void
	{
		vy += 2;
		this.x += vx;
		this.y += vy;
		this.z += vz;
 
		if (vy >= 0 && this.y + rand(RADIUS) >= 465)
		{
			this.y = 465 - RADIUS;
			vy *= -0.9;
 
			this.alpha -= 0.03;
		}
	}
}