2010-03-28 59 views
3

在AS3中創建時,我可以將MovieClip(或其他顯示對象)的註冊點設置爲其中心嗎?在AS3中將MovieClip的註冊點設置到其中心

以下

var myClip:MovieClip = new MovieClip(); 

設置myClip的註冊點在默認情況下它的左上角。使用Flash CS4將其設置爲中心只需幾次點擊,所以我想知道如何才能使用代碼執行相同的操作。

回答

2
myClip.x-= myClip.width/2; 
myClip.y-= myClip.height/2; 
+0

這雖然移動其位置而不是它的中心... – Mirko 2010-05-05 16:33:22

1

這是不正確的,其中_clip是你的影片剪輯使用此代碼:

var dpObj = _clip.getChildAt(0); //the dipslay object or graphic you movie clip contains 
var mat:Matrix = dpObj.transform.matrix; 
var bounds:Rectangle = _clip.getBounds(dpObj); // get the bounds relative to the movie clip 
mat.tx = -bounds.left; //left and top will be the registration point of the clip 
mat.ty = -bounds.top;