矢印

by 084
こういう回転ではなくて、
矢印の中心を軸に回転させたいのですがどうしたらいいのでしょうか?
どうぞよろしくお願いします。
♥0 | Line 30 | Modified 2010-02-03 00:58:54 | MIT License
play

ActionScript3 source code

/**
 * Copyright 084 ( http://wonderfl.net/user/084 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t4SC
 */

//こういう回転ではなくて、
//矢印の中心を軸に回転させたいのですがどうしたらいいのでしょうか?
//どうぞよろしくお願いします。

package {
    import flash.display.Sprite;
	import flash.events.Event;
    public class Main extends Sprite {
		private var arrow:Sprite;
        public function Main() {
           arrow = new Sprite();
		with (arrow.graphics) {
			lineStyle(1, 0, 1);
			beginFill(0xffff00);
			moveTo(60, 70);
			lineTo(90, 70);
			lineTo(90, 60);
			lineTo(120, 80);
			lineTo(90, 100);
			lineTo(90, 90);
			lineTo(60, 90);
			endFill();
		}
		this.addChild(arrow);
		
		arrow.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
	public function onEnterFrame(event:Event):void {
			var dx:Number = mouseX - arrow.x;
			var dy:Number = mouseY - arrow.y;
			var radians:Number = Math.atan2(dy, dx);
			event.target.rotation = radians * 180 / Math.PI;
		}
  }
}

Forked