flexstyle.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<!--http://bbs.5460.net/ss-xs/?uid-10793452-action-viewspace-itemid-635270-->
<mx:Style>
.solidBorder{
color:#FF0000;
fontSize:18;
fontWeight:bold;
}
Button{
fontSize:18;
color:#00FF00;
}
</mx:Style>
<mx:Script source="setStyle.as"/>
<mx:Style source="style.css"/>
<mx:Panel width="447" height="410" layout="absolute" horizontalCenter="0" verticalCenter="0">
<mx:Label id="label1" styleName="solidBorder" text="使用本地样式定义styleName" x="78" y="24" />
<mx:Button label="使用本地样式定义" x="78" y="88" width="185"/>
<mx:Button label="使用内联样式" x="78" y="158" width="120" fontSize="14" color="#000000"/>
<mx:Button label="使用外部样式表" x="78" y="231" width="185" styleName="buttonstyle" />
<mx:Button id="myButton" label="setStyle设置" width="185" fontSize="20" x="78" y="308" color="#000000" styleName="buttonstyle" initialize="initButton();" />
</mx:Panel>
</mx:Application>
style.css
.buttonstyle{
color:#FF0000;
fontSize:18;
fontWeight:bold;
}
setStyle.as
private function initButton():void {
myButton.setStyle("paddingTop",12);
myButton.setStyle("paddingBottom",12);
//myButton.setStyle("width",10);
myButton.setStyle("fontSize",10);
mx.core.Application.application.myButton.label = '使用setStyle设置css'
}