我发现这个项目上传了名为 loadSWFsPlaySequence dot zip ...但不幸的是我遇到了一个大问题:问题:因为我想一个接一个地加载巨大的多个 swf,我应该知道加载的 swf 占用的内存,所以我尝试卸载加载新 swf 时的最后一个 swf 但每次我都失败了...请有人告诉我我是这么愚蠢还是很难...你能帮忙吗?非常感谢...该文件的链接:
在这个项目中,我们有 4 个名为 part1.swf 和 part2.swf 的 swf 文件和 ... part4.swf 。它使用 LoaderMax 加载 4 个 swf 文件并按顺序播放它们。当一个 swf 到达它的最后一帧时,它会告诉下一个 swf 要播放。它工作正常,但是当新的 swf 加载最后一个时,它会停止并且不会卸载。我想在新的 swf 加载时卸载最后加载的 swf ... 这是代码(指向主 fla 文件的链接在这里点击下载:http ://greensock.com/forums/index.php?app=core&module=attach§ion =attach&attach_id=2074 )
这是代码
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
progress_mc.scaleX = 0;
var loaderIndex:Number = -1;
var currentLoader:SWFLoader;
var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler});
swfs.append(new SWFLoader("part1.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part2.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part3.swf", {container:container_mc, autoPlay:false}));
swfs.append(new SWFLoader("part4.swf", {container:container_mc, autoPlay:false}));
function progressHandler(e:LoaderEvent):void {
progress_mc.scaleX = e.target.progress;
}
function childCompleteHandler(e:LoaderEvent):void {
trace(e.target + " loaded");
e.target.content.visible = false;
}
function completeHandler(e:LoaderEvent):void {
trace("all swfs loaded");
progress_mc.visible = false;
initCurrentLoader();
addEventListener(Event.ENTER_FRAME, trackSWFPlayback);
}
function initCurrentLoader() {
loaderIndex++;
if (loaderIndex == swfs.numChildren) {
//reset back to 0 if the last swf has already played
loaderIndex = 0;
}
//dynamically reference current loader based on value of loaderIndex
currentLoader = swfs.getChildAt(loaderIndex);
//make the content of the current loader visible
currentLoader.content.visible = true;
//tell the current loader's swf to to play
currentLoader.rawContent.gotoAndPlay(1);
}
function trackSWFPlayback(e:Event):void {
//trace(currentLoader.rawContent.currentFrame);
//detect if the loaded swf is on the last frame
if (currentLoader.rawContent.currentFrame == currentLoader.rawContent.totalFrames) {
trace("swf done");
//hide and stop current swf
currentLoader.content.visible = false;
currentLoader.rawContent.stop();
//set up and play the next swf
initCurrentLoader();
}
}
load_btn.addEventListener(MouseEvent.CLICK, loadSWFs)
function loadSWFs(e:MouseEvent):void{
load_btn.visible = false;
swfs.load();
}