如何在AS3中创建蒙版?

时间:2011-03-18 16:14:23

标签: actionscript-3

objectToBeMasked.mask = maskObject;

好的,简单......但我可以看看maskObject,除非我将alpha设置为0,然后它不会让点击进入objectToBeMasked

我看到的每一个教程都没有提到这个以及如何解决它,好像它应该是显而易见的。

如何通过AS3屏蔽对象,使掩码像掩码一样,就像IDE中添加的那样?

3 个答案:

答案 0 :(得分:3)

这是一个例子:

var maskedShape : Shape = new Shape();
maskedShape.graphics.beginFill(0x0);
maskedShape.graphics.drawRect(0, 0, 100, 100);
maskedShape.graphics.endFill();
addChild(maskedShape);

var maskerShape : Shape = new Shape(); maskerShape.graphics.beginFill(0x0); maskerShape.graphics.drawRect(0, 0, 100, 100); maskerShape.graphics.endFill(); addChild(maskerShape); maskerShape.x = 20; maskerShape.y = 20;

maskedShape.mask = maskerShape;

答案 1 :(得分:2)

你不应该看到面具。在您尝试应用蒙版时,面具和蒙面对象可能不在舞台上。

你能在这里传递一些代码吗?

答案 2 :(得分:2)

最简单的方法是不将对象简单地设置为visible参数为false:

maskObject.visible = false;

所以你的objectToBeMasked仍然被屏蔽,但是没有抓住鼠标事件,并且不再渲染:)

相关问题