flex动态加载swf皮肤示例代码(flash动态效果)太疯狂了

随心笔谈2年前发布 admin
201 0 0

文章摘要

这篇文章介绍了如何使用Flex API和XML来动态管理CSS样式表。文章通过FlexEvent和styleManager API,展示了如何在点击事件中动态加载和卸载不同的CSS文件。例如,当点击按钮时,代码会依次加载和卸载不同的样式文件(如`style01.swf`、`style02.swf`和`style03.swf`)。此外,文章还使用`setTimeout`方法控制了样式加载和卸载的时间顺序,确保了操作的流畅性。

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″

creationComplete=”initHandler(event)”>

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”;

}

]]>

© 版权声明

相关文章