两种办法
1在影片剪辑最后一帧加脚本
dispatchEvent(new Event("finish"));
然后在loader上加监听器
loader.contentLoaderInfo.addEventListener("complete",comHandler);
function comHandler(event:Event):void{
loader.contentLoaderInfo.removeEventListener("complete",comHandler);
loader.content.addEventListener("finish",finishHandler);
}
function finishHandler(event:Event):void{
loader.content.removeEventListener("finish",finishHandler);
loader.parent.removeChild(loader);
}
2直接在loader上加监听
loader.contentLoaderInfo.addEventListener("complete",comHandler);
function comHandler(event:Event):void{
loader.contentLoaderInfo.removeEventListener("complete",comHandler);
loader.addEventListener("enterFrame",enterFrameHandler);
}
function enterFrameHandler(event:Event):void{
if(MovieClip(loader.content).totalFrames==MovieClip(loader.content).currentFrame);
loader.removeEventListener("enterFrame",enterFrameHandler);
loader.parent.removeChild(loader);
}
推荐使用第一种方法,效率比较高