开发者

Converting uint color to argb hexadecimal for kml color

Good day everyone,

I am stuck trying to convert a uint color value into its equivalent argb hexadecimal format. Basically, 开发者_开发知识库I am trying to convert a color from Flex(AS3) into its appropriate kml color, which is in the argb hexadecimal format from what I gather. Below is my function as it stands now. Although it does convert into a valid kml color, it is not the right color or even close. Does anyone see anything wrong here?

    private static function getKmlColor(color:uint,alpha:Number):String
    {
        var argb:uint = 0;
        var alphaUint:uint = 255 * alpha;
        argb += (alphaUint<<24);
        argb += (color);
        return argb.toString(16);
    }  


I assume your alpha is something between 0 and 1 (0-100%) so that should be fine, although I'd probably make it a double and then floor or ceiling to the nearest whole number.

But the rest seems OK

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜