# AS3: Mask within a Mask (or how to use a shape with a hole in it as a mask)

**URL:** <https://forum.kirupa.com/t/as3-mask-within-a-mask-or-how-to-use-a-shape-with-a-hole-in-it-as-a-mask/274345>\
**Category:** flash\
**Created:** [October 28, 2008, 7:23pm UTC](https://forum.kirupa.com/t/as3-mask-within-a-mask-or-how-to-use-a-shape-with-a-hole-in-it-as-a-mask/274345 "2008-10-28T19:23:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grax\_Bishop](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@Grax\_Bishop](https://forum.kirupa.com/u/Grax_Bishop)\
**Post date:** [October 28, 2008, 7:23pm UTC](https://forum.kirupa.com/t/as3-mask-within-a-mask-or-how-to-use-a-shape-with-a-hole-in-it-as-a-mask/274345/1 "2008-10-28T19:23:39Z")

</div>

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:

![](http://forum.kirupa.com/uploads/kirupa/5024/e8db8e8ec73d937f.jpg)

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:

![](http://forum.kirupa.com/uploads/kirupa/5025/f19de939158d137e.jpg)

However what I am actually getting is the yellow rectangle is masking the movieclip, but is ignoring the hole within it:

![](http://forum.kirupa.com/uploads/kirupa/5026/766c7751edb48a42.jpg)

This is the AS3 code that I’ve written to get the above effect (with ‘maskee’ being the movieclip that contains the drawings):

```auto

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. 😃
