Actionscript 3 as3 MovieClip未正确缩放

Actionscript 3 as3 MovieClip未正确缩放,actionscript-3,positioning,scaling,movieclip,Actionscript 3,Positioning,Scaling,Movieclip,我正试图在主菜单中设置按钮。我有一个名为MenuAchievementsButton的类,在其构造函数中,它从document类向下传递stage width和stage height。当我追踪这个时,它是正确的宽度/高度 我想把按钮的高度设为舞台高度/100。我试过这样做。高度=舞台高度/100,但每当我这样做时,它会给我4倍我想要的结果,即使我输入一个数字,比如5,然后在Photoshop中测量px 另外,当我试图移动物体时,也存在类似的问题:当我想让它左右移动20像素时,结果是左右移动80

我正试图在主菜单中设置按钮。我有一个名为MenuAchievementsButton的类,在其构造函数中,它从document类向下传递stage width和stage height。当我追踪这个时,它是正确的宽度/高度

我想把按钮的高度设为舞台高度/100。我试过这样做。高度=舞台高度/100,但每当我这样做时,它会给我4倍我想要的结果,即使我输入一个数字,比如5,然后在Photoshop中测量px

另外,当我试图移动物体时,也存在类似的问题:当我想让它左右移动20像素时,结果是左右移动80像素

感谢您的帮助

    package menus {

import flash.display.MovieClip;


public class MenuAchievementsButton extends MovieClip {
    private var _stageWidth, _stageHeight:int;

    public function MenuAchievementsButton(stageWidth:int, stageHeight:int) {
        _stageWidth = stageWidth;
        _stageHeight = stageHeight;

        alpha = 1;
        rescaleMe();
        repositionMe();
        trace(_stageWidth, _stageHeight);
    }

    private function rescaleMe():void {
        var oldWidth = this.width;
        var oldHeight = this.height;

        this.height = _stageHeight/100;
        this.width = (this.height * oldWidth) / oldHeight;
    }

    private function repositionMe():void {
        this.x = 20;
        this.y = 20;
        trace(x,y,width,height);
        trace("Stage height is: ",_stageHeight,"Stage height divided by 100 is: ", _stageHeight/100, "And the object's height, which should be stageheight / 100 is:", this.height);
        //Gives Stage height is:  800 Stage height divided by 100 is:  8 And the object's height, which should be stageheight / 100 is: 8
        //Actually, though, it's 36px!
    }
}

}代码似乎是正确的。没有问题

类的实例是否已添加到后台?或者在其他物体上

查看是否不更改父对象的比例,如下所示:

var parentMC:MovieClip=new MovieClip();
addChild(parentMC);

var rectangle:Shape = new Shape; // initializing the variable named rectangle
rectangle.graphics.beginFill(0xFF0000); // choosing the colour for the fill, here it is red
rectangle.graphics.drawRect(0, 0, 100,100); // (x spacing, y spacing, width, height)
rectangle.graphics.endFill(); // not always needed but I like to put it in to end the fill
parentMC.addChild(rectangle); // adds the rectangle to the stage

trace(rectangle.width) // result 100

parentMC.scaleX=2;
trace(rectangle.width) // result 100 altough it looks like it has 200

当我尝试使用scaleX=1时,它会使它变得更大!我查过了,这个物体不在舞台上或其他物体里。。。有什么想法吗?我找到了解决方案——我从主菜单背景中创建按钮,它已经缩放。谢谢你的帮助!:D@user2696186是的,缩放始终相对于父对象,而不是全局对象。