Hi guys,
I’ve been stuck on this AS 3 masking problem for days now. I’m sure there’s a simple solution to my problem but it’s proving to be a pain.
I have a movieclip that contains some drawings, bitmap, etc. on top of that I am drawing a yellow rectangle with a hole in it using ActionScript:
What I want to achieve is to mask the movieclip container using the yellow rectangle, but I want the hole in the middle to not show the drawings and line:
However what I am actually getting is the yellow rectangle is masking the movieclip, but is ignoring the hole within it:
This is the AS3 code that I’ve written to get the above effect (with ‘maskee’ being the movieclip that contains the drawings):
function drawRectMask(p_sprite:Sprite) : void {
p_sprite.graphics.beginFill(0xf0ff00);
p_sprite.graphics.drawRect(100,100,300, 300);
p_sprite.graphics.moveTo(100,200);
p_sprite.graphics.drawRect(150,150,100, 100);
p_sprite.graphics.endFill();
}
var spr:Sprite = new Sprite();
drawRectMask(spr);
addChild(spr);
maskee.mask = spr ;
I’m at wits end. Any help on this would be greatly appreciated.