I need to have a swf play on top of开发者_如何学运维 another swf after a certain amount of time.
can someone provide a code to help me out?
Thanks in advance!
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.net.URLRequest;
import flash.utils.Timer;
import flash.utils.getTimer;
public class Test extends Sprite
{
private var _loader : Loader;
private var _loadedSWF : MovieClip;
private var _timer : Timer;
public function Test()
{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
_loader.load(new URLRequest("OtherSWF.swf"));
_timer = new Timer(1000, 1);
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
}
private function onLoadComplete(event : Event) : void
{
trace("onLoadComplete: " + getTimer());
// add to displaylist
_loadedSWF = event.currentTarget.content;
_loadedSWF.stop();
_loadedSWF.visible = false;
addChild(_loadedSWF);
// start timer
_timer.start();
}
private function onTimerComplete(event : TimerEvent) : void
{
trace("onTimerComplete: " + getTimer());
_loadedSWF.visible = true;
_loadedSWF.play();
}
}
}
http://kb2.adobe.com/cps/141/tn_14190.html
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html
精彩评论