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

small life

Get Adobe Flash player
by kiyobu 30 Mar 2010
    Embed
/**
 * Copyright kiyobu ( http://wonderfl.net/user/kiyobu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t0Mt
 */

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.geom.ColorTransform;
    import flash.filters.GlowFilter;
    [SWF(width = "465", height = "465", backgroundColor = "0x226633", frameRate = "30")]
    public class FlashTest extends Sprite {
    		public var layer:Array = new Array();
    		public var list:Array = new Array();
        public function FlashTest() {
	        	layer[0] = new Bitmap(new BitmapData(stage.stageWidth,stage.stageHeight, true, 0x00000000));
        		layer[1] = new Sprite();
        		for(var i:uint = 0; i < 64; i++){
        			list.push(new Point2(random(stage.stageWidth),random(stage.stageHeight),2));
        		}
        		addChild(layer[0]);
        		addChild(layer[1]);
        		layer[1].filters = [new GlowFilter(0x33cc66,1,16,16,4,3)];
            addEventListener(Event.ENTER_FRAME, loop)
        }
        public function loop(e:Event):void {
        		var lgh:uint = list.length;
        		layer[1].graphics.clear();
        		layer[1].graphics.lineStyle(1,0xffffff,1);
        		for(var i:uint = 0; i < lgh; i++){
        			list[i].x += random(4) * (random(2) * 2 -1);
        			list[i].y += random(4) * (random(2) * 2 -1);
        			if (list[i].x > stage.stageWidth){
        				list[i].x -= stage.stageWidth;
        			} else if (list[i].x < 0){
        				list[i].x += stage.stageWidth;
        			}
        			if (list[i].y > stage.stageHeight){
        				list[i].y -= stage.stageHeight;
        			} else if (list[i].y < 0){
        				list[i].y += stage.stageHeight;
        			}
        			layer[1].graphics.drawCircle(list[i].x, list[i].y, list[i].r);
        			for(var j:uint = i +1; j < lgh; j++){
        				if (Point.distance(list[i],list[j]) < list[i].r + list[j].r){
        					list[i].r += list[j].r;
        					list[i].x = (list[i].x + list[j].x)/2;
        					list[i].y = (list[i].y + list[j].y)/2;
        					list.splice(j,1);
        					j--;
        					lgh --;
        				}
        			}
        		}
        		var cash:BitmapData = new BitmapData(stage.stageWidth, stage.stageWidth, true, 0x00000000);
        		cash.draw(this,null,new ColorTransform(1,1,1,0.8),BlendMode.ADD);
        		layer[0].bitmapData = cash;
        }
        public function random(n:Number):Number {
        		return Math.floor(Math.random() * n);
        }
    }
}
import flash.geom.Point;
dynamic class Point2 extends Point{
	public var r:Number;
	public function Point2(xx:Number,yy:Number,rr:Number){
		x = xx;
		y = yy;
		r = rr;
	}
}