# Bitmap mask on Sprite

**URL:** https://forum.kirupa.com/t/bitmap-mask-on-sprite/233118
**Category:** flash
**Created:** [July 20, 2007, 9:42am UTC](https://forum.kirupa.com/t/bitmap-mask-on-sprite/233118 "2007-07-20T09:42:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)
#### Post date: [July 20, 2007, 9:42am UTC](https://forum.kirupa.com/t/bitmap-mask-on-sprite/233118/1 "2007-07-20T09:42:29Z")

</div>

Hello,

Basicly I have a background rectangle with a ‘dynamic’ color like this:

[AS]  
var myRect:Sprite = new Sprite();  
myRect.graphics.beginFill(_color);  
myRect.graphics.drawRect(0,0,image.width,image.height);  
myRect.graphics.endFill();  
myRect.name = "bg_"+\_name;  
this.rawChildren.addChild(myRect);  
[/AS]

And a bitmap mask like this (which is a transparent png with a white object on it):

[AS]  
var image:Bitmap = Bitmap(\_loader.content);  
var bitmap:BitmapData = new BitmapData(image.width,image.height,true);  
bitmap.draw(image, new Matrix());  
var masker:Bitmap = new Bitmap(bitmap);  
[/AS]

And the mask is applied like this:

[AS]  
myRect.mask = masker;  
[/AS]

But this just displays my complete rectange and not the cut out mask. Anyone a solution for this?

Thanks in advance :huh:
