将影片剪辑与根/阶段影片剪辑对齐

发布于 2024-08-30 05:06:39 字数 1088 浏览 17 评论 0原文

如何将动态影片剪辑位置与根舞台中的另一个影片剪辑对齐? 我尝试将 mc 置于 root x,y 位置,但加载动态 MC 的类的起点似乎不准确。 (意味着在根阶段,x,y 是 0,0,但在动态类中,浏览器区域的值类似于 100,20(实际上它根据浏览器大小而变化))

**我使用的其他类为了运行下面的自定义类,我已将此 MC 添加到舞台

var blocker:stageBlocker=new stageBlocker();
        this.stage.addChild(blocker);

下面是动态 MC。我不应该将它添加到自己的“舞台”吗?

public class stageBlocker extends MovieClip {

    private var blocker:MovieClip= new MovieClip();

    public function stageBlocker():void {
        addEventListener(Event.ADDED_TO_STAGE, add2Stage);
    }
    private function add2Stage(event:Event):void {
        createBlocker();
    }

    private function createBlocker():void {
        blocker.graphics.beginFill(0x000000,0.9);
        blocker.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
        blocker.graphics.endFill();
        addChild(blocker);
        blocker.x=main.vC.x
    }

    public function removeBlocker():void {
        blocker.graphics.clear();
        removeChild(blocker);
        removeEventListener(Event.ADDED_TO_STAGE, add2Stage);
    }
}

How do you align a dynamic movie clip position with another movie clip which is in the root stage?
I tried to get the mc in root x,y position, but the starting point of the class that loads the dynamic MC does not seems to be accurate.
(Meaning at the root stage, the x,y is 0,0 but at the dynamic class, its somewhere like 100,20 for the browser area (and it actually vary base on the browser size))

**the other classes I used to run the custom classes below, I have it added this MC to stage

var blocker:stageBlocker=new stageBlocker();
        this.stage.addChild(blocker);

Below is the dynamic MC. Should I not add it to its own "stage"?

public class stageBlocker extends MovieClip {

    private var blocker:MovieClip= new MovieClip();

    public function stageBlocker():void {
        addEventListener(Event.ADDED_TO_STAGE, add2Stage);
    }
    private function add2Stage(event:Event):void {
        createBlocker();
    }

    private function createBlocker():void {
        blocker.graphics.beginFill(0x000000,0.9);
        blocker.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
        blocker.graphics.endFill();
        addChild(blocker);
        blocker.x=main.vC.x
    }

    public function removeBlocker():void {
        blocker.graphics.clear();
        removeChild(blocker);
        removeEventListener(Event.ADDED_TO_STAGE, add2Stage);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初与友歌 2024-09-06 05:06:39

尝试将舞台对齐设置为左上角:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

Try setting the stage aligment to top left:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文