0 Replies Latest reply on Jan 12, 2011 2:43 AM by Ibarim-0Ohkzh

    Mask transparent on left and right.

    Ibarim-0Ohkzh

      Hi,

       

      I want to create a mask on a object. The mask should be gradient: transparent on left side, opaque inside and transparent on the right side. It should be opaque on full height so I cannot use GradientType.RADIAL. But when I use GradientType.LINEAR it's transparent only on one side. Full code below:

       


      var mask:Canvas = new Canvas;
      mask.cacheAsBitmap = true;
      mask.x = hbPics.x;
      mask.y = hbPics.y;
      mask.width = hbPics.width;
      mask.height = hbPics.height;

      var mat:Matrix= new Matrix();
      var colors:Array=[0xFFFFFF,0xFFFFFF];
      var alphas:Array=[1,0];
      var ratios:Array=[150,255];
      mat.createGradientBox(hbPics.width,hbPics.height);
      mask.graphics.lineStyle();
      mask.graphics.beginGradientFill(GradientType.LINEAR,colors,alphas,ratios,mat);
      mask.graphics.drawRect(0,0,hbPics.width,hbPics.height);
      mask.graphics.endFill();

      addChild(mask);
      hbPics.mask = mask;

       

      Any ideas how to create such mask I'm looking for?