The following code works with Flash but doesn’t work on OpenFL (next and legacy).
var current = Lib.current;
var stage = current.stage;
var circle = new Bitmap(new BitmapData(50, 50, true, 0x00000000), PixelSnapping.ALWAYS, true);
var box = new Bitmap(new BitmapData(50, 50, true, 0xFFFFFFFF), PixelSnapping.ALWAYS, true);
var cs = new Shape();
cs.graphics.beginFill(0xFF00FF, 1);
cs.graphics.drawCircle(25, 25, 20);
cs.graphics.endFill();
circle.bitmapData.draw(cs);
var boxSprite = new Sprite();
var cirSprite = new Sprite();
boxSprite.addChild(box);
cirSprite.addChild(circle);
boxSprite.cacheAsBitmap = true;
cirSprite.cacheAsBitmap = true;
current.addChild(boxSprite);
// current.addChild(cs);
current.addChild(cirSprite);
// boxSprite.mask = cs;
boxSprite.mask = cirSprite;
Making using Shape works correctly, but unfortunately I need to use bitmap mask because the mask shape would be complex to recreate using Shape (not a basic shape) and even if I could recreate it in shape I thought it would cause a performance hit?.