views:

57

answers:

1

Hello,

I would like to have a variable transparency for a Flex UI container. The upper half of the container should be completely opaque but the lower part of it should smoothly change from completely opaque to completely transparent.

Any ideas how to achieve it?

Thanks

+2  A: 

You can use a gradient fill to achieve this.

var fillType:String = GradientType.LINEAR;
var colors:Array = [0xffffff, 0xffffff];
var alphas:Array = [1, 0];
var ratios:Array = [127, 255];
var mat:Matrix = new Matrix();
mat.createGradientBox(bkg.width, bkg.height, 90, 0, 0);

bkg.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, 
         ratios, mat, SpreadMethod.PAD);  

bkg.graphics.drawRect(0, 0, bkg.width, bkg.height);
Amarghosh
Thanks for the proposal. I tried this approach but it only achieves the desired effect for the container's background. The problem is that in a Container there may be a lot of children (UI components) and I would like to achieve such transparency for everything in the Container.
Flexer