利用BlendMode做镂空擦除效果

import flash.display.BlendMode;
import flash.events.MouseEvent;
import flash.display.Shape;
var bg:Sprite = new Sprite;
bg.graphics.beginFill(0xffcc00);
bg.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
bg.graphics.endFill();
bg.blendMode = BlendMode.LAYER;
this.addChild(bg);
bg.addEventListener(MouseEvent.CLICK,onClick);
 
//var child:Shape = new Shape;
var box:Sprite = new Sprite;
box.graphics.beginFill(0xffcc00);
box.graphics.drawRect(100, 100, 200, 200);
box.graphics.endFill();
box.blendMode = BlendMode.ERASE;
bg.addChild(box);
box.addEventListener(MouseEvent.CLICK,onClickchild);
function onClick(e:MouseEvent):void
{
trace("bg");
}
function onClickchild(e:MouseEvent):void
{
trace("box");
}
原文地址:https://www.cnblogs.com/chenhongyu/p/3342057.html