利用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");
}
posted on 2013-09-27 02:41  猎妖手  阅读(583)  评论(0编辑  收藏  举报