开发者

Aligning Movieclip with root/stage Movieclip

How do you align a d开发者_StackOverflow社区ynamic 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);
    }
}


Try setting the stage aligment to top left:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜