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-4-6

2010年4月6日
ひとまず、広がる輪のテスト
Get Adobe Flash player
by tenasaku 06 Apr 2010
    Embed
/**
 * Copyright tenasaku ( http://wonderfl.net/user/tenasaku )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/scN1
 */

// 2010年4月6日
// ひとまず、広がる輪のテスト

package {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	public class FlashTest extends Sprite {
		private var wawawa:Array;
		private var tf:TextField;
		private var frameCount:int = 0;
		private function drawHorizon():void {
			this.graphics.clear();
			this.graphics.beginFill(0x000000);
			this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
			this.graphics.endFill();
    		}
		private function onResize(e:Event):void {
			drawHorizon();
		}
    		private function atEveryFrame(e:Event):void {
			var i:int;
			tf.text = "frame: " + (frameCount++).toString();
			for ( i = 0 ; i < wawawa.length ; ++i ) {
				if ( wawawa[i].life() <= 0 ) {
					var dead:Array = wawawa.splice(i,1,new Wakka(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight,20,0xffffff));
					this.removeChild(dead[0]);
					this.addChild(wawawa[i]);
				} else {
	    				wawawa[i].spread();
				}
			}
    		}
    		private function initialize(e:Event):void {
    			stage.align = StageAlign.TOP_LEFT;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
			drawHorizon();
			tf = new TextField();
			tf.textColor = 0xff0000;
			tf.autoSize = TextFieldAutoSize.LEFT;
			addChild(tf);
			wawawa = new Array;
			while ( wawawa.length < 10 ) {
				wawawa.push(new Wakka(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight,20,0xffffff));
			}
			var wa:Wakka;
			for each ( wa in wawawa ) {
				this.addChild(wa);
			}
			stage.addEventListener(Event.RESIZE, onResize);
   			stage.addEventListener(Event.ENTER_FRAME, atEveryFrame);
    		}
		public function FlashTest() {
			if ( stage != null ) {
				initialize(null);
			} else {
				this.addEventListener(Event.ADDED_TO_STAGE, initialize);
			}
		}
	}
}

import flash.display.*;
class Wakka extends Shape {
	private var radius:Number ;
	private var original_radius:Number;
	private var color:Number;
	public function life():Number {
		if ( stage != null ) {
			var W:Number = stage.stageWidth;
			var H:Number = stage.stageHeight;
			var D00:Number = Math.sqrt(x*x+y*y);
			var D01:Number = Math.sqrt(x*x+(H-y)*(H-y));
			var D10:Number = Math.sqrt((W-x)*(W-x)+y*y);
			var D11:Number = Math.sqrt((W-x)*(W-x)+(H-y)*(H-y));
			return Math.max(D00-radius,D01-radius,D10-radius,D11-radius,0);
		} else {
			return 0;
		}
	}
	public function spread():void {
		radius += 5;
		alpha *= 0.99;
		scaleX = radius/original_radius;
		scaleY = scaleX;
	}
	public function Wakka(_x:Number,_y:Number,_r:Number,cc:uint) {
		x = _x;
		y = _y;
		this.graphics.clear();
		this.graphics.lineStyle(2,cc,1,false,LineScaleMode.NONE);
		this.graphics.drawCircle(0,0,_r);
		radius = _r;
		original_radius = _r;
	}
}