开发者

Changing the alpha with ColorTransform (tint + alpha)?

开发者 https://www.devze.com 2023-03-08 17:17 出处:网络
I am trying to change the alpha of a tint using the ColorTransform class, is开发者_JS百科 it possible to do this?

I am trying to change the alpha of a tint using the ColorTransform class, is开发者_JS百科 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消