How do I over-ride the alpha settings on the createJS Container children?

20 Views Asked by At

I am using createJS and have constructed a Container containing two bitmaps

var content = new createjs.Container(); content.addChild(bkground, foreground);

if I set content.alpha = 0.5 I can see part of the bkground through the foreground item. How do I over-ride the alpha settings on the createJS Container children?

I hope that makes some sense? Cheers Andy

I have tried some of the options you can set on Container but nothing seems to work

1

There are 1 best solutions below

0
Skeptigon On

The alpha of a container is imposed on its children, and so on down the tree. A child can't override its container's alpha, or more precisely its containers' alphas. A child's alpha is the product of its alpha and all of its parents' alphas.

So, if the parent has a .5 alpha, all of its children (and the children's children) will have their alphas forcibly reduced by 50%. If, for example, a child itself had a .5 alpha and was in a parent also with a .5 alpha, the child would would appear on the stage as .25 alpha. You must multiply all the alphas from the display object up to the stage to get the representative alpha.