我正在使用几种颜色作为uint的组件,但我的颜色格式为“#161616”。我不确定两种颜色之间的关系是什么,或者如何从一种颜色到另一种颜色。
它不一定是动作脚本解决方案。我只有少量的这些颜色,所以也可以手动完成。
答案 0 :(得分:38)
var color:uint = 0x161616;
或者,以编程方式转换它们:
var s:String = "#161616";
var color:uint = uint("0x" + s.substr(1));
答案 1 :(得分:3)
请注意,Flex中的样式表需要#FFFFFF ... NOT 0xFFFFFF形式的颜色值。 MXML元素样式属性并不关心。虽然你开始写的东西是:
<mx:VBox backgroundColor="
Intellisense会提示您输入uint值;如果你继续这样完成它
<mx:VBox backgroundColor="#FFFFFF"></VBox>
它仍会使你的backgroundColor与你写的
相同<mx:VBox backgroundColor="0xFFFFFF"></VBox>
答案 2 :(得分:1)
这里有两个我的utils函数:
public static function convertUintToString( color:uint ):String {
return color.toString(16);
}
public static function convertStringToUint(value:String, mask:String):uint {
var colorString:String = "0x" + value;
var colorUint:uint = mx.core.Singleton.getInstance("mx.styles::IStyleManager2").getColorName( colorString );
return colorUint;
}
答案 3 :(得分:1)
正确的方法是使用StyleManager.getColorName()
查看完整的documentation
答案 4 :(得分:0)
var i : uint = uint("0x161616");