flex动态加载swf皮肤示例代码
更新时间:2013年09月26日 17:34:32 作者:
动态加载swf皮肤,对经常使用flex的朋友来说并不陌生,在本文为大家详细介绍下具体的实现方法,感兴趣的朋友可以参考下
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="initHandler(event)">
<fx:Script>
<![CDATA[
import flash.utils.clearTimeout;
import flash.utils.setTimeout;
import mx.events.FlexEvent;
private var styleurl:String="";
private var setTimeout2:uint;
protected function initHandler(event:FlexEvent):void
{
styleurl="style01.swf";
styleManager.loadStyleDeclarations(styleurl,true);
}
protected function t1_clickHandler(event:MouseEvent):void
{
if(styleurl!=null)
{
styleManager.unloadStyleDeclarations(styleurl,true);
}
styleManager.loadStyleDeclarations("style02.swf",true);
styleurl="style02.swf";
}
protected function button1_clickHandler(event:MouseEvent):void
{
setTimeout2 = setTimeout(button1_click,2000);
}
private function button1_click():void
{
if(styleurl!=null)
{
styleManager.unloadStyleDeclarations(styleurl,true);
}
styleManager.loadStyleDeclarations("style03.swf",true);
styleurl="style03.swf";
clearTimeout(setTimeout2);
}
protected function button2_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(styleurl!=null)
{
styleManager.unloadStyleDeclarations(styleurl,true);
}
styleManager.loadStyleDeclarations("style01.swf",true);
styleurl="style01.swf";
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Panel horizontalCenter="0" y="100" width="422" height="300" title="用户登录">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle" gap="28"/>
</s:layout>
<s:HGroup verticalAlign="middle">
<s:Label text="用户名"/>
<s:TextInput id="t1" styleName="textInput" prompt="请输入用户名"/>
</s:HGroup>
<s:HGroup verticalAlign="middle" paddingLeft="20">
<s:Label text="密码" id="t2"/>
<s:TextInput styleName="textInput" prompt="请输入密码"/>
</s:HGroup>
<s:controlBarContent>
<s:Button label="小粉红" click="t1_clickHandler(event)" color="0xFF00FF"/>
<s:Button label="经典蓝(2秒)" click="button1_clickHandler(event)" color="0x4169E1"/>
<s:Button label="青草绿(默认)" click="button2_clickHandler(event)" color="0x00FF00"/>
</s:controlBarContent>
<s:controlBarLayout>
<s:HorizontalLayout gap="39"/>
</s:controlBarLayout>
</s:Panel>
</s:Application>
复制代码 代码如下:
/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
global
{
color:#dc143c;
fontFamily:"微软雅黑";
borderColor:#caff70;
fontSize:20;
borderWeight:3;
}
s|Panel
{
backgroundColor:"#00FF00";
backgroundAlpha:0.3;
}
s|TextInput
{
color:#ff0000;
fontFamily:"微软雅黑";
borderColor:#ffff00;
fontSize:20;
}
s|Button
{
paddingleft:"10";
paddingtop:"5";
}
.textInput
{
color:#cd8500;
fontFamily:"微软雅黑";
borderColor:#ff0000;
fontSize:20;
}
#t1
{
color:#00ff00;
fontFamily:"微软雅黑";
borderColor:#0000ff;
fontSize:20;
}
#t2
{
color:#0000ff;
fontFamily:"微软雅黑";
borderColor:#ff00ff;
fontSize:20;
}
复制代码 代码如下:
/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
global
{
color:#191970;
fontFamily:"微软雅黑";
borderColor:#caff70;
fontSize:20;
borderWeight:3;
}
s|Panel
{
backgroundColor:"#E066FF";
}
s|TextInput
{
fontFamily:"微软雅黑";
borderColor:#ffff00;
fontSize:20;
}
.textInput
{
fontFamily:"微软雅黑";
borderColor:#ff0000;
fontSize:20;
}
#t1
{
color:"#00FFFF";
fontFamily:"微软雅黑";
borderColor:#0000ff;
fontSize:20;
}
复制代码 代码如下:
/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
global
{
color:"#388E8E";
fontFamily:"微软雅黑";
borderColor:#caff70;
fontSize:20;
borderWeight:3;
}
s|Panel
{
backgroundColor:"#00B2EE";
}
s|TextInput
{
fontFamily:"微软雅黑";
borderColor:#ffff00;
fontSize:20;
}
.textInput
{
fontFamily:"微软雅黑";
borderColor:#ff0000;
fontSize:20;
}
#t1
{
color:"#6B8E23";
fontFamily:"微软雅黑";
borderColor:#0000ff;
fontSize:20;
}
相关文章
Flex中的HDividedBox和VDividedBox的比较附图
学习Flex的朋友对HDividedBox和VDividedBox并不陌生吧,下面是两者的简单比较,感兴趣的朋友可以参考下2013-10-10Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色
本节主要介绍了Flex DataGrid根据条目某一属性值改变背景颜色,此DataGrid为自定义拓展的,需要的朋友可以参考下2014-07-07
最新评论