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

万華鏡

ドラッグすると動きます
コードが汚いです。
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4moJ
 */

// ドラッグすると動きます
//コードが汚いです。

package
{
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.net.URLRequest;
        import flash.system.Security;
	
[SWF(width='465',height='465',backgroundColor='0x00',frameRate='30')]
	public class TriCir extends Sprite
	{
		private var _stg:Sprite;
		private var list:Array = [];
		private var g:BitmapData;
		
		public function TriCir()
		{
			_stg = addChild(new Sprite())as Sprite;
			
			var maru:Shape = addChild(new Shape())as Shape
			maru.graphics.beginFill(0xff0000,0.5);
			maru.graphics.drawCircle(stage.stageWidth/2,stage.stageHeight/2,150);
			maru.graphics.endFill();
			_stg.mask = maru;
			
			Security.loadPolicyFile("http://www.178design.com/crossdomain.xml");
			 var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, com);
			loader.load(new URLRequest("http://www.178design.com/swf/wonderfl/1.jpg"));
			
			function com(e:Event):void
			{
				init(loader);
			}
		}
		
		private function init(loader:Loader):void
		{
			g = new BitmapData(200,150);
			g.draw(loader);
			var xx:Number;
			var yy:Number;
			var w:Number;
			var h:Number;
			for(var i:uint=0; i<3; i++)
			{
				xx = stage.stageWidth/2;
				yy = stage.stageHeight/2;
				
				var n:One = _stg.addChild(new One(g))as One;
				Create(n,0,xx,yy);
				
				if(i==0)
				{
					w = n.width;
					h = n.height;
				}
				
				var nh:One = _stg.addChild(new One(g))as One;
				Create(nh,60,xx,yy,-1);
				
				xx = stage.stageWidth/2 + h*2*Math.cos((i*120-30)*Math.PI/180);
				yy = stage.stageHeight/2 + h*2*Math.sin((i*120-30)*Math.PI/180);
				
				var rn:One = _stg.addChild(new One(g))as One;
				Create(rn,-120,xx,yy,1,-1);
				
				var rh:One = _stg.addChild(new One(g))as One;
				Create(rh,120,xx,yy);
				
				var rh2:One = _stg.addChild(new One(g))as One;
				Create(rh2,0,xx,yy);
				
				xx = stage.stageWidth/2 + h*2*Math.cos((i*120+30)*Math.PI/180);
				yy = stage.stageHeight/2 + h*2*Math.sin((i*120+30)*Math.PI/180);
				
				var r2n:One = _stg.addChild(new One(g))as One;
				Create(r2n,120,xx,yy);
				
				var r2h:One = _stg.addChild(new One(g))as One;
				Create(r2h,180,xx,yy,-1);
				
				var r2h2:One = _stg.addChild(new One(g))as One;
				Create(r2h2,60,xx,yy,-1);
			}
			
			function Create(o:One,rot:int,xx:Number,yy:Number,sx:int=1,sy:int=1):void
			{
				o.rotation = i*120+rot;
				o.scaleX = sx;
				o.scaleY = sy;
				o.x = xx;
				o.y = yy;
				list.push(o);
			}
			
			Play();
		}
		
		private function Play():void
		{
			stage.addEventListener(MouseEvent.MOUSE_DOWN,down);
			stage.addEventListener(MouseEvent.MOUSE_UP,up);
			var len:uint = list.length;
			var pm:Point = new Point(mouseX,mouseY);
			var mx:Number = mouseX-pm.x;
			var my:Number = mouseY-pm.y;
			var gg:BitmapData = g.clone();
			
			function down(e:MouseEvent):void
			{
				mx = my = 0;
                                pm.x = mouseX;
				pm.y = mouseY;
				gg = g.clone();
				stage.addEventListener(MouseEvent.MOUSE_MOVE,move);
			}
			
			function up(e:MouseEvent):void
			{
				stage.removeEventListener(MouseEvent.MOUSE_MOVE,move);
				for(var q:uint=0; q<len; q++)
				{
					list[q].nx = list[q].ny = -100;
					list[q].UP(g,0,0);
				}
			}
			
			function move(e:MouseEvent):void
			{
				mx = mouseX-pm.x;
				my = mouseY-pm.y;
				
				for(var q:uint=0; q<len; q++)
				{
					list[q].UP(gg,mx,my);
				}
				
				pm.x = mouseX;
				pm.y = mouseY;
			}
		}
	}
}
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.display.BitmapData;
	import flash.geom.Matrix;

class One extends Sprite
{
	private var ss:Shape;
	private var mtr:Matrix = new Matrix();
	public var nx:Number = -100;
	public var ny:Number = -100;
	
	public function One(a:BitmapData)
	{
		ss = addChild(new Shape())as Shape;
		mtr.createBox(1,1,0,-100,-100);
		UP(a,0,0);
		ss.y =ss.height;
	}
	
	public function UP(_src:BitmapData,mx:Number,my:Number):void
	{
		nx += mx;
		ny += my;
		mtr.createBox(1,1,0,nx,ny);
		ss.graphics.clear();
		ss.graphics.beginBitmapFill(_src,mtr);
		
		var p:Point = Point.polar(50,30*Math.PI/180);
		var p1:Point = Point.polar(50,150*Math.PI/180);
		var p2:Point = Point.polar(50,270*Math.PI/180);
		
		ss.graphics.moveTo(p.x,p.y-p.y);
		ss.graphics.lineTo(p1.x,p1.y-p.y);
		ss.graphics.lineTo(p2.x,p2.y-p.y);
		ss.graphics.lineTo(p.x,p.y-p.y);
		ss.graphics.endFill();
	}
}