【发布时间】:2011-04-04 16:51:42
【问题描述】:
是否有任何开源 flash/actionscript 代码可以在 x 秒内显示图像。
【问题讨论】:
标签: flash actionscript-3 actionscript
是否有任何开源 flash/actionscript 代码可以在 x 秒内显示图像。
【问题讨论】:
标签: flash actionscript-3 actionscript
var ldr:Loader;
var timer:Timer;
function showImage(url:String, seconds:Number):void
{
ldr = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest(url));
timer = new Timer(seconds * 1000, 1);
timer.addEventListener(TimerEvent.TIMER, onTimer);
}
function onLoad(e:Event):void
{
addChild(ldr.content);
timer.start();
ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoad);
}
function onTimer(e:TimerEvent):void
{
removeChild(ldr.content);
ldr.unload();
timer.removeEventListener(TimerEvent.TIMER, onTimer);
}
【讨论】: