flash / actionscript显示x秒的图像

时间:2010-08-27 08:56:19

标签: flash actionscript-3 actionscript

是否有任何开源flash / actionscript代码可以显示x秒的图像。

1 个答案:

答案 0 :(得分:1)

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);
}