使用brush_mc,您可以刷过一个蒙版,这会将像素在画笔描边中变为透明。所以在视觉上它会擦除蒙版,并出现蒙版的影片剪辑。我想追踪,如果面具完全变成透明。
是否可以在没有位图数据的情况下检查蒙版是否完全透明?
// this creates a mask that hides the movieclip on top
var mask_mc:MovieClip = new MovieClip();
addChild(mask_mc)
//assign the mask to the movieclip it should 'cover'
mc1.mask = mask_mc;
//add event listeners for the 'brush'
brush_mc.addEventListener(MouseEvent.MOUSE_DOWN,brushDown);
brush_mc.addEventListener(MouseEvent.MOUSE_UP,brushUp);
//function to drag the brush over the mask
function brushDown(dragging:MouseEvent):void{
dragging.currentTarget.startDrag();
MovieClip(dragging.currentTarget).addEventListener(Event.ENTER_FRAME,erase) ;
mask_mc.graphics.moveTo(brush_mc.x,brush_mc.y);
}
//function to stop dragging the brush over the mask
function brushUp(dragging:MouseEvent):void{
dragging.currentTarget.stopDrag();
MovieClip(dragging.currentTarget).removeEventListener(Event.ENTER_FRAME,erase);
}
//fill the mask with transparant pixels so the movieclip turns visible
function erase(e:Event):void{
with(mask_mc.graphics){
beginFill(0x000000);
drawRect(brush_mc.x,brush_mc.y,brush_mc.width,brush_mc.height);
endFill();
}
}