views:

269

answers:

1

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);
    }
}
A: 

Try setting the stage aligment to top left:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
Cristi Băluță
I've tried that, but when the blocker is called, the whole stage/screen position would changed. That's why I wanted to see if there's anyway to let it run its position based on the root/stage. I'm now trying on localToGlobal but still does not understand how to use it.
Hwang
or is there a way to change the stage.align back to center after i remove it. AS3 does not seems to have the align to center code anymore :(
Hwang
Probably if you set it to null will center. But i think you designed it badly if you need that. I don't understand too much from what you're trying to do but i'm doing every application aligned to top_left and i never had problems.
Cristi Băluță