使用brush_mc,您可以將其塗抹在遮罩上,使畫筆中的像素變爲透明。 因此,它視覺上擦除蒙版,並出現蒙面影片剪輯。 我想跟蹤,如果面具完全變成透明。AS3可以檢查面罩是否完全填充?
是否有可能檢查如果沒有bitmapdata掩碼是完全透明的?
// 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();
}
}
我對As3很新,所以解釋可能有點偏離,但這是爲了讓我的自我更清楚。隨時糾正我 – Opoe
你爲什麼不想使用bitmapdata? – grapefrukt
@grapefrukt我想使用它,但我認爲如果可以只用蒙版來完成,它會更容易理解。但是,我嘗試了一些bitmapdata的東西,但無法讓它工作。如果您有任何建議,歡迎! – Opoe