views:

18

answers:

1

Is there any opensource flash/actionscript code to display an image for x number of seconds.

+1  A: 
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);
}
Amarghosh