将影片剪辑与根/阶段影片剪辑对齐
如何将动态影片剪辑位置与根舞台中的另一个影片剪辑对齐? 我尝试将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将舞台对齐设置为左上角:
Try setting the stage aligment to top left: