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

錯視

渦巻きに見える
Get Adobe Flash player
by cpu_t 10 Jan 2010
/**
 * Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9nRS
 */

// 渦巻きに見える
package {
	import flash.display.Graphics;
	import flash.display.Shape;
    import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.geom.Point;
	
	[SWF (width = 400, height = 400, backgroundColor = 0x808080)]
    public class FlashTest extends Sprite {
		private var _srcCircle:Shape;
		
        public function FlashTest() {
			const size:int = stage.stageWidth;
			x = size * 0.5;
			y = size * 0.5;
			
			_srcCircle = new Shape();
			var t:Number = 0;
			var r:Number = size;
			var d:Number = 100;
            var pt:Point;
			var g:Graphics = _srcCircle.graphics;
			g.lineStyle(0, 0x000000, 0.0);
			var tmpPt:Point;
			var color:uint = 0x000000;
			var angle:Number = 0;
			var angled:Number = 10;
			while (angle < Math.PI * 2) {
				g.beginFill(color, 1.0);
				pt = Point.polar(r, angle);
				tmpPt = Point.polar(d, angle + Math.PI / 2);
				g.moveTo(pt.x, pt.y);
				pt = pt.add(tmpPt);
				g.lineTo(pt.x, pt.y);
				angle += angled * Math.PI / 180;
				pt = Point.polar(r, angle);
				tmpPt = Point.polar(d, angle + Math.PI / 2);
				tmpPt = tmpPt.add(pt);
				g.lineTo(tmpPt.x, tmpPt.y);
				g.lineTo(pt.x, pt.y);
				g.endFill();
				color = 0xFFFFFF - color;
			}
			addChild(_srcCircle);
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
		
		private var cnt:int = 1;
		private function enterFrameHandler(e:Event):void 
		{
			cnt++;
			if (cnt % 20==0) {
				cnt = 0;
				var sp:Sprite = new Sprite;
				sp.graphics.copyFrom(_srcCircle.graphics);
				sp.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
					var mat:Matrix = sp.transform.matrix;
					mat.scale(0.98, 0.98);
					if (mat.a < 0.01) {
						removeChild(sp);
					} else sp.transform.matrix = mat;
					
				});
				addChild(sp);
			}
		
		}
    }
}