在flex定义样式的几种方法

来源:互联网 发布:星星知我心 编辑:程序博客网 时间:2024/05/16 05:49

1.使用外部样式表

<mx:Style source="myStyle.css"/>

2.在内部定义一个自定义样式表

<mx:Style>
     .myFontStyle { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" styleName="myFontStyle" label="Click Here"/>

3.定义整体控件样式

<mx:Style>
     Button { fontSize: 15 }
</mx:Style>
<mx:Button id="myButton" label="Click Here"/>

4.使用StyleManager类设置样式

getStyleDeclaration()方法获取样式名称,然后使用setStyle()方法定义样式

StyleManager.getStyleDeclaration("TextArea").setStyle("fontSize",15);

5.直接用控件的setStyle()方法

myButton.setStyle("fontSize", 15);

6.在控件中直接使用样式属性定义

<mx:Button id="myButton" fontSize="15" label="My Button"/>