1 Reply Latest reply on Jul 20, 2007 4:42 AM by jeroencornelissen

    Bitmap mask on Sprite

    jeroencornelissen
      Hello,

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

      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);

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

      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);

      And the mask is applied like this:

      myRect.mask = masker;


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

      Thanks in advance