flex 动态加载CSS

本文转自:http://hi.baidu.com/yitao/blog/item/b78f921363205d856438db66.html
原文出处:
http://blog.flexexamples.com/2007/12/12/loading-cascading-style-sheets-on-the-fly-using-the-flex-stylemanager-class/

使用 静态方法:
StyleManager.loadStyleDeclarations()


效果展示:
http://blog.flexexamples.com/wp-content/uploads/StyleManager_loadStyleDeclarations_test/bin/main.html

----------
代码说明:

<?xml version="1.0" encoding="utf-8"?><!-- http://blog.flexexamples.com/2007/12/12/loading-cascading-style-sheets-on-the-fly-using-the-flex-stylemanager-class/ --><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"        layout="vertical"        verticalAlign="middle">    <mx:Script>        
<![CDATA[           
 import mx.styles.StyleManager;            
private function loadStyles(styleURL:String):void {
           StyleManager.loadStyleDeclarations(styleURL);
            
}        
]]>    
</mx:Script>    
<mx:ApplicationControlBar dock="true">       
 <mx:ComboBox id="comboBox"    prompt="Please select a style"   change="loadStyles(comboBox.selectedItem.data);">            <mx:dataProvider>               
 <mx:Array>                   
 <mx:Object label="red" data="styles/red.swf" />                  
 <mx:Object label="green" data="styles/green.swf" />                   
 <mx:Object label="blue" data="styles/blue.swf" />               
 </mx:Array>           
 </mx:dataProvider>       
 </mx:ComboBox>    
</mx:ApplicationControlBar>
</mx:Application>

下面时css文件,注意,要将css转换为 swf. 右键单击 css文件 选择convert css to swf.


/* blue.css */Application { backgroundColor: haloBlue;}
/* green.css */Application { backgroundColor: haloGreen;}
/* red.css */Application { backgroundColor: red;}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值