1 Reply Latest reply on Apr 10, 2012 10:58 PM by Patel Bharat

    Add circular mask to bitmapData...

    Chipleh Level 3

      Hi,

       

      I'm not sure how to go about this in Flex. I have this code:

       

      override public function set data( value:Object ) : void

      {

           super.data = value;               

           image.source = new Bitmap(BitmapData(value));               

           image.smoothBitmapContent = true;

      }

       

      ... which creates a nice square color. I want to mask it with a circle and am hoping there's a simple way to go about doing so. Can anyone provide a some code or examples on how to accomplish this?

       

      Thank you!

      ~Chipleh

        • 1. Re: Add circular mask to bitmapData...
          Patel Bharat Level 2

          Add a mask and to get circle mask on image set appropiate rounded conrner according to image object size. I think this would be helpful to you:

           

          var roundedMask = new Sprite();

          var cornerRadius:uint = 60;

          roundedMask.graphics.clear();

          roundedMask.graphics.beginFill(0xFF0000);

          roundedMask.graphics.drawRoundRect(0, 0, image.width, image.height, cornerRadius, cornerRadius);

          roundedMask.graphics.endFill();

           

          addChild( roundedMask);

          image.mask = roundedMask;