仔细看了一下HitArea api,其实可以使用HitArea的hit与unHit属性结合destination-out实现flash中两次draw镂空可点击穿透完全一致的效果。[code]var redBox:Sprite = new Sprite();
redBox.pos(250,200);
redBox.autoSize = true;
redBox.graphics.drawRect(0,0,100,100,'#ff0000');
Laya.stage.addChild(redBox);
redBox.on("click",this,function(){
trace("click redbox");
});
redBox.on("mouseover",this,function(){
redBox.graphics.clear();
redBox.graphics.drawRect(0,0,100,100,'#00ff00');
});
redBox.on("mouseout",this,function(){
redBox.graphics.clear();
redBox.graphics.drawRect(0,0,100,100,'#ff0000');
});
var guideContainer:Sprite = new Sprite();
guideContainer.autoSize = true;
guideContainer.pos(120,150);
guideContainer.cacheAs = "bitmap";
guideContainer.alpha = 0.5;
Laya.stage.addChild(guideContainer);
guideContainer.on("click",this,function(){
trace("click guideContainer");
});
guideContainer.on("mouseover",this,function(){
sp1.graphics.clear();
sp1.graphics.drawRect(0,0,300,300,'#00ff00');
});
guideContainer.on("mouseout",this,function(){
sp1.graphics.clear();
sp1.graphics.drawRect(0,0,300,300,'#000000');
});
var hit:Graphics = new Graphics();
hit.drawRect(0, 0, 300,300, "#ff0000");
var unhit:Graphics = new Graphics();
unhit.drawCircle(150, 150, 50, "#ff0000");
var area:HitArea = new HitArea();
area.hit = hit;
area.unHit = unhit;
guideContainer.hitArea = area;
guideContainer.mouseEnabled = true;
var sp1:Sprite = new Sprite();
sp1.graphics.drawRect(0,0,300,300,'#000000');
guideContainer.addChild(sp1);
var sp2:Sprite = new Sprite();
sp2.pos(150,150);
sp2.blendMode = "destination-out";
sp2.graphics.drawCircle(0,0,50,'#000000');
guideContainer.addChild(sp2);[/code]