, , , ...:)
blendMode BlendMode.ERASE cacheAsBitmap. , , , .
:
var cheese:Sprite = new Sprite();
cheese.cacheAsBitmap = true;
stage.addChild(cheese);
cheese.x = cheese.y = 10;
var holes:Shape = new Shape();
holes.blendMode = BlendMode.ERASE;
cheese.addChild(holes);
var g = cheese.graphics;
g.beginFill(0xFFCC00);
g.drawRect(0,0,200,150);
g = holes.graphics;
for (var i:int = 0; i < 10; i++){
g.beginFill(0xFF00FF);
var hx = Math.random()*(cheese.width-7)+7;
var hy = Math.random()*(cheese.height-7)+7;
var s = Math.random()*15;
g.drawCircle(hx, hy, s);
g.endFill();
}
The result will be something like this:

change
Turns out you don't need to use cacheAsBitmapif you set the parent object's blending mode to LAYER(doc says it should be set automatically ...) So you can use cheese.blendMode = BlendMode.LAYER;instead cheese.cacheAsBitmap = true;. And if I remember correctly, masks also do not require cahceAsBitmap, even with blending mode NORMAL.
source
share