设置style(安优先级排序):
1. 直接设置
var myButton:Button;
myButton.setStyle(“fontSize”, 20);
2. 使用CSS对象设置(styleName)
var styleObj = new mx.styles.CSSStyleDeclaration();
styleObj.setStyle(“fontSize”, 20);
styleObj.setStyle(“fontWeight”, “bold”);
styleObj.setStyle(“color”, 0x00ff00);
myButton.setStyle(“styleName”, styleObj);
或
_global.styles.newStyle = styleObj;
myButton.setStyle(“styleName”, “newStyle”);
或(属于下一优先级,不建议使用)
myButton.className = “styleName”;
myButton.invalidateStyle();
3. 设置Class的Style
if (_global.styles.CheckBox == undefined) {
_global.styles.CheckBox = new mx.styles.CSSStyleDeclaration();
}
_global.styles.CheckBox.setStyle(“color”, 0x0000FF);
其中CheckBox是组件的ClassName
4. 继承的Style
这写Style都可以从Container处继承
l fontFamily
l fontSize
l fontStyle
l fontWeight
l textAlign
l textIndent
l All single-value color styles
5. 全局Style
_global.style.setStyle(“fontSize”, 20);
所有颜色相关的 style 都是即时有效的。可以使用颜色名字来设置颜色 style 。颜色名字可以用 mx.styles.styleManager.registerColorName() 进行注册。