css样式文件可以编译成swf文件导入到程序中,来改变组件的样式。
右键css文件,选择complie css to swf选项
代码:
- <?xml?version="1.0"?encoding="utf-8"?>?
-
<s:TitleWindow?xmlns:fx="http://ns.adobe.com/mxml/2009"? ?
-
???????????????xmlns:s="library://ns.adobe.com/flex/spark"? ?
-
???????????????xmlns:mx="library://ns.adobe.com/flex/mx"?xmlns:cccccc="cccccc.*"? ?
-
???????????????width="400"?height="300"?creationComplete="init()">?
-
????<fx:Declarations>?
-
?????????
-
????</fx:Declarations>?
-
????<fx:Script>?
-
????????<![CDATA[ ?
- ????????????public?function?init():void{ ?
- ????????????????this.styleManager.loadStyleDeclarations("style.swf"); ?
- ????????????} ?
- ???????????? ?
- ????????????protected?function?button1_clickHandler(event:MouseEvent):void ?
- ????????????{ ?
- ????????????????this.styleManager.loadStyleDeclarations("style2.swf"); ?
- ????????????} ?
- ???????????? ?
- ????????]]>?
-
????</fx:Script>?
-
????<mx:VBox?width="100%"?height="100%"?verticalAlign="middle"?horizontalAlign="center">?
-
????????<s:Button?label="222222222211"?click="button1_clickHandler(event)"/>?
-
????????<s:Button?label="222222222222"/>?
- ???????? ?
-
????????<s:Button?label="333333333333"/>?
-
????????<s:Button?label="444444444444"/>?
- ???????? ?
-
????</mx:VBox>? ?
-
</s:TitleWindow>?
以上代码是在一个TitleWindow里面动态的导入两个css文件编译成的swf文件,点击按钮的时候,会切换另一个swf文件,经测试确实可以改变容器内组件的样式。