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

not a coincidence typeR

// forked from Kay's not a coincidence
package {
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Matrix;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.events.Event;
	[SWF(width="400", height="400", backgroundColor="0xffddff")]
	public class Take02 extends Sprite {
		private const SW:Number = stage.stageWidth;
		private const SH:Number = stage.stageHeight;
		private var dotP:Vector.<Point> = new Vector.<Point>();
		private var dotD:Vector.<Number> = new Vector.<Number>();
		private var dotR:Vector.<Number> = new Vector.<Number>();
		private var dotV:Vector.<int> = new Vector.<int>();
		private var ind:int = 0;
		private var pos:Number = 0;
		private const dotRadius:Number = 2;
		private var colors:Array = [0xff0000, 0x0000ff];
		public function Take02():void {
			// 到達位置を決める
			var textformat:TextFormat = new TextFormat();
			textformat.bold = true;
			textformat.font = "Arial Black";
			textformat.size = 80;
			var textfield:TextField = new TextField();
			textfield.defaultTextFormat = textformat;  
			textfield.autoSize = "left"; 
			textfield.text = "wonderfl";
			var bitmapdata:BitmapData = new BitmapData(SW,SH,true,0x000000);
			var matrix:Matrix = new Matrix();
			matrix.translate((SW-textfield.width)/2,(SH-textfield.height)/2);
			bitmapdata.draw(textfield,matrix);
			for (var nY:uint = 0; nY <= SH; nY+=(dotRadius*2)) {
				for (var nX:uint = 0; nX<= SW; nX+=(dotRadius*2)) {
					if (bitmapdata.hitTest(new Point(0,0), 0x00, new Point(nX, nY))) {
						var dist:Number = Math.random()*90+10;
						var radian:Number = Math.random()*Math.PI*2;
						var center:Point = Point.polar(dist,radian);
						center.offset(nX,nY);
						dotP.push(center)
						dotD.push(dist);
						dotR.push(radian);
						dotV.push((Math.floor(Math.random()*2))==1?1:-1);
					}
				}
			}
			addEventListener(Event.ENTER_FRAME, run);
		}
		private function run(e:Event):void {
			graphics.clear();
			pos = (ind/360)*Math.PI*2;
			dotP.forEach(drawDot);
			ind = ind+4;
		}
		private function drawDot(item:Point, index:int, vector:Vector.<Point>):void {
			var nX:Number = item.x + dotD[index]*Math.cos(dotR[index]+pos*dotV[index]);
			var nY:Number = item.y + dotD[index]*Math.sin(dotR[index]+pos*dotV[index]);
			graphics.beginFill(0xff0000);
			graphics.drawCircle(nX,nY,dotRadius);
			graphics.endFill();
		}
	}
}