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

drip

Get Adobe Flash player
by Scmiz 22 May 2011
/**
 * Copyright Scmiz ( http://wonderfl.net/user/Scmiz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bEg1i
 */

package {
	import flash.display.Graphics;
    import flash.display.Sprite;
	import flash.events.Event;
    public class FlashTest extends Sprite {
		private var _prevColor:uint;
		private var _currentColor:uint;
		private var _array:/*Data*/Array;
		
        public function FlashTest() {
			stage.frameRate = 60;
			_prevColor = 0xffffff;
			_currentColor = _prevColor;
			
			changeColor();
			
			this.addEventListener(Event.ENTER_FRAME, proc);
        }
		
		private function proc(e:Event):void {
			var g:Graphics = this.graphics;
			g.clear();
			g.beginFill(_prevColor);
			g.drawRect(0, 0, 465, 465);
			g.endFill();
			
			var draw:Function = function(x:Number, y:Number, size:Number):void {
				g.beginFill(_currentColor);
				g.drawCircle(x, -size, size);
				g.endFill();
				g.beginFill(_currentColor);
				g.drawRect(x - size, -size, size * 2, y + size);
				g.endFill();
				g.beginFill(_currentColor);
				g.drawCircle(x, y, size);
				g.endFill();
			}
			
			var isAllEnd:Boolean = true;
			for (var index:uint = 0; index < _array.length; ++index) {
				var datum:Data = _array[index];
				
				if (!datum.isEnd) {
					isAllEnd = false;
					datum.y += datum.speed;
					if (datum.y > 465) {
						datum.isEnd = true;
					}
				}
				draw(datum.x, datum.y, datum.size);
			}
			
			if (isAllEnd) {
				changeColor();
			}
		}
		
		private function changeColor():void {
			_prevColor = _currentColor;
			
			var r:uint = 64 + (192 * Math.random());
			var g:uint = 64 + (192 * Math.random());
			var b:uint = 64 + (192 * Math.random());
			_currentColor = (r << 16) + (g << 8) + (b << 0);
			
			_array = new Array();
			var x:Number = 0;
			while (x < 465) {
				var size:Number = 15 + (Math.random() * 25);
				var speed:Number = 3 + (Math.random() * 2);
				_array.push(new Data(x, size, speed));
				x += size;
			}
		}
    }
}

class Data {
	public var x:Number;
	public var y:Number;
	public var size:Number;
	public var speed:Number;
	public var isEnd:Boolean;
	
	public function Data(x:Number, size:Number, speed:Number) {
		this.x = x;
		this.y = -size;
		this.size = size;
		this.speed = speed;
		this.isEnd = false;
	}
}