flash as3加载两个swf,等前一个播放完之后,再播放后一个。
在 fla文件中的第一帧写上以下代码:
var loader1:Loader = new Loader();
var loader2:Loader = new Loader();
loader1.load(new URLRequest("1.swf"));
loader2.load(new URLRequest("2.swf"));
loader1.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
var mc:MovieClip;
function completeHandler(e:Event):void
{
trace("1.swf加载完成");
addChild(loader1);
trace("e.currentTarget.loader.content:" + e.currentTarget.loader.content);
mc = e.currentTarget.content.getChildAt(0) as MovieClip;
mc.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
function enterFrameHandler(e:Event):void
{
trace("e.currentTarget.currentFrame:" + e.currentTarget.currentFrame);
trace("e.currentTarget.totalFrames:" + e.currentTarget.totalFrames);
if(e.currentTarget.currentFrame == e.currentTarget.totalFrames)
{
mc.removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
trace("done");
//loader1.unload();
removeChild(loader1);
addChild(loader2);
}
}
var loader2:Loader = new Loader();
loader1.load(new URLRequest("1.swf"));
loader2.load(new URLRequest("2.swf"));
loader1.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
var mc:MovieClip;
function completeHandler(e:Event):void
{
trace("1.swf加载完成");
addChild(loader1);
trace("e.currentTarget.loader.content:" + e.currentTarget.loader.content);
mc = e.currentTarget.content.getChildAt(0) as MovieClip;
mc.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
function enterFrameHandler(e:Event):void
{
trace("e.currentTarget.currentFrame:" + e.currentTarget.currentFrame);
trace("e.currentTarget.totalFrames:" + e.currentTarget.totalFrames);
if(e.currentTarget.currentFrame == e.currentTarget.totalFrames)
{
mc.removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
trace("done");
//loader1.unload();
removeChild(loader1);
addChild(loader2);
}
}
想说的 就是 1.swf 舞台只有一帧,这时候你得获取它上面的mc (谁播放动画就去判断谁) 当前帧currentFrame 和 总帧totalFrames 。