redconservatory
redconservatory

Reputation: 21924

Changing the alpha with ColorTransform (tint + alpha)?

I am trying to change the alpha of a tint using the ColorTransform class, is it possible to do this?

private function setColor(target:DisplayObject, color:uint, alpha:uint = 150) {
            var colorTransform = new ColorTransform();
            colorTransform.color = color;
            colorTransform.alphaOffset = alpha;
            target.transform.colorTransform = colorTransform;
        }

However, when I try to use it with say,

setColor(this, 0x333333, 100);

I seem to get a solid dark grey instead of a partially transparent tint?

Upvotes: 3

Views: 4867

Answers (1)

Simon Eyraud
Simon Eyraud

Reputation: 2435

Use alpha alphaMultiplier instead of alphaOffset. When you use alphaOffset, it add alpha, so if alpha is already at 100% you won't see any transparency.

Upvotes: 5

Related Questions