Bitmap mask on Sprite

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: