2011年1月17日 星期一

[AS3] 目標實體的rotationX、rotationY值隨 mouseX、mouseY 與stage寬高中線的正負距離而漸變轉動

1000117_DisplayObject__mouseX_rotationY_2.swf






import flash.ui.Mouse;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
//
var disX:int;
var disY:int;
//
plane.x = stage.stageWidth/2;
plane.y = stage.stageHeight/2;
//
stage.addEventListener(MouseEvent.MOUSE_MOVE, rotateXY);
//
function rotateXY(e:MouseEvent):void{
 disX = mouseX - Math.ceil(stage.stageWidth/2);
 disY = mouseY - Math.ceil(stage.stageHeight/2);
 plane.rotationY = disX/7;
 plane.rotationX = disY/7;
}

沒有留言: