flex动态加载swf皮肤示例代码

所属分类: 网络编程 / Flex 阅读数: 1952
收藏 0 赞 0 分享
复制代码 代码如下:

<?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 tomcat端口被占用的问题分析及解决方法

在启动Tomcat,提示8080端口被占用了,该如何解决呢?本文整理了一些修改方法,感兴趣的朋友可以参考下,希望可以帮助到你
收藏 0 赞 0 分享

flash 报错捕获(Catch All Exception in Flash)

就是在全局任何地方产生的错误如果没有被捕获,都可以在捕获阶段和冒泡阶段被捕获,接下来为大家介绍一种可以捕捉所有错误的方法,感兴趣的你可不要错过了哈
收藏 0 赞 0 分享

flex 开发项目报错之404错误解决方案

最近两天被HttpStates404这个错误折腾的够呛,查了很多的文章都是大同小异,接下来为大家介绍下详细的解决方法,感兴趣的各位可以参考下哈,希望可以帮助到你
收藏 0 赞 0 分享

Flex动态生成可编辑的DataGrid具体实现代码

DataGrid具有以下功能:表头是动态生成的、每行都是有序号的、每行都是可以编辑、插入、删除、修改,接下来为大家分享下Flex如何动态生成可编辑的DataGrid
收藏 0 赞 0 分享

flex打印操作(FlexPrintJob)还有分页打印操作具体实现

如果要使用分页效果,则必须使用标签"PrintAdvancedDataGrid"(Flex3中的标签)才能够实现分页效果,感兴趣的朋友可以参考下
收藏 0 赞 0 分享

flex中event.preventDefault()方法取消事件的默认行为

当点击datagrid的第一和第四项时,itemEdit事件将不起作用,许多事件都有默认执行的关联行为,接下来为大家详细介绍下,感兴趣的朋友可以参考下哈
收藏 0 赞 0 分享

flex4.5中CSS选择器的应用小结

与HTML相似,Flex允许在MXML标签中通过CSS样式来设置组件的外观。到flex4.5后已经基本上支持了HTML中的所有CSS的应用方式,这里主要来列举下flex4.5中CSS选择器的使用方法
收藏 0 赞 0 分享

Flex Label控件竖排显示文字的实现代码

Label控件竖排显示文字一般都是横排的,接下来为大家分享个方法让它变成竖排,感兴趣的童鞋们可以学习下,希望对你有所帮助
收藏 0 赞 0 分享

flex4 panel去掉标题设置透明度效果代码

首先:去掉Panel的标题,其次:设置透明度这个说了也是啰嗦,大家都会,不过还是提一下吧,具体请祥看本文
收藏 0 赞 0 分享

Flex自定义右键菜单具体实现

自定义右键菜单在flex的实现想必有很多朋友都没有尝试过吧,下面与大家分享下如何实现,具体代码如下
收藏 0 赞 0 分享
查看更多