# Masking problem

**URL:** <https://forum.kirupa.com/t/masking-problem/287972>\
**Category:** Uncategorized\
**Created:** [May 8, 2009, 5:06pm UTC](https://forum.kirupa.com/t/masking-problem/287972 "2009-05-08T17:06:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebrofm](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@sebrofm](https://forum.kirupa.com/u/sebrofm)\
**Post date:** [May 8, 2009, 5:06pm UTC](https://forum.kirupa.com/t/masking-problem/287972/1 "2009-05-08T17:06:37Z")

</div>

hey guys, so i am having trouble getting a png(in bitmapdata form) from my library to mask a sprite that is loaded into the movie via loader.

so my setup is:  
mainThumb : Sprite //empty sprite to contain bitmap loaded via loader  
thumbMask : Sprite //sprite from the library that contains a png to be used as a mask for mainThumb  
overlay : Bitmap //some effects to overlay image  
thumb : Bitmap //bitmap loaded using loader to be added to mainThumb

from library:  
Thumb\_Mask : Sprite //the sprite in the library containing the png  
Thumb\_Overlay : BitmapData

and the code (that isn’t working)

```auto

function init(e:Event) : void { //called from contentloaderinfo's Event.COMPLETE
    var thumb:Bitmap = e.target.content;
    thumb.smoothing = true;

    mainThumb = new Sprite();
    mainThumb.addChild(thumb);

    var overlay:Bitmap = new Bitmap(new Thumb_Overlay(0,0));
    var thumbMask:Sprite = new Thumb_Mask();

    mainThumb.x = overlay.x = thumbMask.x = -mainThumb.width/2;
    mainThumb.mask = thumbMask;

    this.addChild(mainThumb);
    this.addChild(overlay);

...

```

i feel like this should work… but it doesn’t, nothing shows up at all using this code, but when i try commenting out the masking line, and adding addChild(thumbMask),the mask shows up in the correct position

any ideas why this isn’t working?

thanks a ton

edit: when i add the line, mainThumb.cacheAsBitmap = true, i see mainThumb but it is not masked…
