1000117_DisplayObject__mouseX_rotationY_3.swf
import flash.ui.Mouse; import flash.events.MouseEvent; import caurina.transitions.Tweener; import flash.display.BitmapData; import flash.display.MovieClip; import flash.display.Bitmap; // var disX:int; var disY:int; // var plane:MovieClip = new MovieClip(); addChild(plane); var bmd:BitmapData = new MyPhoto(); var bm:Bitmap = new Bitmap(bmd); plane.addChild(bm); bm.scaleX = 0.9; bm.scaleY = 0.9; //bm左上角原對齊在plane的註冊點(0,0),調整bm中心點位置使對齊plane的註冊點(0,0) bm.x = - bm.width/2; bm.y = - bm.height/2; //由於bm中心點位置經上述調整,正對齊plane的註冊點(0,0),也對齊stage的(0,0) //想把plane從stage的(0,0)移動stage的中央,必須將stage的寬與高各除以2,指定給plane.x和plane.y 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/16; plane.rotationX = -disY/16; }
沒有留言:
張貼留言