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 yoropan 15 Feb 2009
    Embed
package {
	import flash.display.*;
	import flash.events.Event;
	public class main extends MovieClip {

		private var vp={x:0,y:0,z:0,zoom:0,rotate:0};
		private var point_arr=[];
		private var _mc_arr=[];
		//private var c:Circle;

		public function main() {
			addstage();
			this.addEventListener(Event.ENTER_FRAME,effect);
			this.addEventListener(Event.ENTER_FRAME,render);
		}
		public function addstage() {
			var point;
			var _mc:Circle;
			for (var i=0; i<50; i++) {
				//ポイントを格納
				point={x:Math.random()*550,y:Math.random()*400};
				point_arr[i]=point;
				//MCを格納
				//_mc=new box();
				_mc = new Circle();
				_mc_arr[i]=_mc;
				addChild(_mc);
			}
		}

		private function effect(e:Event) {
			//移動とか
			//vp.x+=2;
			//回転

			vp.rotate+=.1;
			//trace(vp.x);
		}
		private function render(e:Event) {

			que3();
		}
		private function que3() {
			//addstageしたけど座標が(0,0)
			//回転の中心を移動
			vp.x=250;
			vp.y=200;
			for (var i=0; i<_mc_arr.length; i++) {
				//いったん格納したものを取り出して使う
				var point=point_arr[i];
				var _mc=_mc_arr[i];
				//視点からポイントの差を使って回転

				var disX=point.x-vp.x;
				var disY=point.y-vp.y;
				var cos=Math.cos(vp.rotate);
				var sin=Math.sin(vp.rotate);
				_mc.x=disX*cos-disY*sin+250;
				_mc.y=disX*sin+disY*cos+200;
			}
		}


	}

}
	import flash.display.*;
class Circle extends MovieClip {
	//import flash.display.*;
	public function Circle() {
		var c:MovieClip=new MovieClip();
		c.graphics.beginFill( 0xcccc33);
		c.graphics.lineStyle( 1, 0xfffffff );
		c.graphics.drawCircle( 10, 10, 10 );
		c.graphics.endFill();
		addChild(c)
	}
}