flex动态加载swf皮肤示例代码
程序员文章站
2022-03-07 18:45:01
复制代码 代码如下:
<?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;
}
复制代码 代码如下:
<?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;
}