4 Replies Latest reply on Apr 27, 2009 1:26 PM by run,ryan!

    masking problem


      I'm trying to mask an image and show the mask - see the attached code below.

      This code displays the image and the mask.

      However, if I uncomment the last line in init(), nothing is displayed.


      Why ?


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          creationComplete="init()" >
                  private function init():void {
                      var radius:Number = targetImage.height/2;
                      var moonMask:Shape = new Shape();
                      moonMask.graphics.drawCircle(radius, radius, radius);
                      var bd:BitmapData = new BitmapData( moonMask.width, moonMask.height );
                      bd.draw( moonMask );
                      maskImage.source = new Bitmap(bd);
                      //targetImage.mask = maskImage;
          <mx:VBox >
              <mx:Image id="maskImage" height="100%" width="100%"  />
              <mx:Image id="targetImage" height="100%" width="100%"
                    source="@Embed(source='../resources/moonMap.png')"  />