六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 243|回复: 0

flex 动态加载CSS

[复制链接]

升级  9.33%

14

主题

14

主题

14

主题

秀才

Rank: 2

积分
64
 楼主| 发表于 2013-2-8 00:57:29 | 显示全部楼层 |阅读模式
本文转自: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;}
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表