我有一个容器MovieClip,用作我需要屏蔽的内容区域。当我使用形状创建此容器内的面膜我似乎无法与我在这里创建了其他容器的内容交互,如按钮等Actionscript 3和动态蒙版
这是我在代码正在做(我已经离开出所有进口的等):
class MyContainer extends MovieClip
{
protected var masker : Shape = null;
protected var panel : MyPanel = null;
public function MyContainer()
{
this.masker = new Shape();
this.masker.graphics.clear();
this.masker.graphics.beginFill(0x00ff00);
this.masker.graphics.drawRect(0, 0, 1, 1); // 1x1 pixel.
this.masker.graphics.endFill();
addChild(this.masker);
this.panel = new MyPanel(); // has buttons and stuff.
addChild(this.panel);
this.mask = this.masker;
}
// called by it's parent when the stage is resized.
public function resize(width : Number, height : Number) : void
{
// set the mask to half the size of the stage.
this.masker.width = width/2;
this.masker.height = height/2;
// set the panel to half the size of the stage.
this.panel.resize(width/2, height/2);
}
}
当我的面具(形状)添加到显示层次,我可以不再与MyPanel中定义的所有的按钮交互。但是,而不是将掩码添加到显示层次结构中可以让我与MyPanel上的内容进行交互,但掩码的大小/位置不正确。我想,当掩码没有添加到显示层次时,它位于电影的左上角(我不能证明这一点)。
如何去正确地做我的面具大小/位置,让用户在MyPanel按钮互动?
但是masker是一个Shape,因此没有mouseEnabled属性。这是我使用Shape而不是Sprite的原因。 – Luke 2009-07-07 01:41:08