在Flash中使用style

来源:互联网 发布:最好用的cms 编辑:程序博客网 时间:2024/05/16 11:10

设置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.      设置ClassStyle

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()进行注册。
原创粉丝点击