我有一個容器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