I know that this was a long time ago, but only for people who may be looking for the same problem. It is actually quite simple (as long as you use Sprite with a graphics class).
1) Rigid hole cutting:
this.graphics.beginFill(0x666666); this.graphics.drawRect(0,0,256, 256); this.graphics.drawCircle(128,128,32); this.graphics.endFill();
this will create a 256 by 256 rectangle with a 64px hole in it.
2) Flexible hole cutting:
Obviously this will not work if you are not using a graphics class. In this case, I would go with BlendMode.ERASE .
var spr:Sprite = new Sprite(); var msk:Sprite = new Sprite(); addChild(spr); spr.addChild(msk) spr.graphics.beginFill(0x666666); spr.graphics.drawRect(0,0,256, 256); spr.graphics.endFill(); msk.graphics.beginFill(0x000000); msk.graphics.drawEllipse(0,0,64,64); msk.graphics.endFill(); msk.x = 128; msk.y = 128; spr.blendMode = BlendMode.LAYER; msk.blendMode = BlendMode.ERASE;
When using BlendMode.ERASE you should ALWAYS set the blendmode parentcontainer to BlendMode.LAYER, otherwise it will not work.
I hope this can help someone
Pjetr source share