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

forked from: 錯視 (Fixed exception)

ひとまず例外出ないようにした。でも CPU 食いまくり!
----------------------------------------------------
渦巻きに見える
Get Adobe Flash player
by nitoyon 11 Jan 2010
/**
 * Copyright nitoyon ( http://wonderfl.net/user/nitoyon )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7I8R
 */

// forked from cpu_t's 錯視
// ひとまず例外出ないようにした。でも CPU 食いまくり!
//----------------------------------------------------
// 渦巻きに見える
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);
                                                sp.removeEventListener("enterFrame", arguments.callee);
					} else sp.transform.matrix = mat;
					
				});
				addChild(sp);
			}
		
		}
    }
}