如何在加载新swf时卸载上次加载的swf?

时间:2016-09-07 07:45:44

标签: flash load greensock loadermax

我发现这个项目上传名为loadSWFsPlaySequence dot zip ... 但不幸的是我遇到了一个大问题: 问题: 因为我想一个接一个地加载巨大的和多个swfs我应该知道加载swfs的内存,所以我尝试在加载新的swf时卸载最后的swf,但每次我失败... 请有人告诉我,我是愚蠢的,还是很难...... 你能帮我吗 ? 非常感谢 ... 链接到该文件:

在这个项目中我们有4个名为part1.swf的swf文件和part2.swf以及... part4.swf。它使用LoaderMax加载4个swf文件并按顺序播放它们。当swf到达它的最后一帧时,它会告诉下一个swf进行播放。它工作正常,但是当新的swf加载最后一个只是停止并且没有卸载。我想在新的swf加载时卸载最后加载​​的swf ... 这是代码(链接到主fla文件在这里点击下载:http://greensock.com/forums/index.php?app=core&module=attach&section=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();
}

0 个答案:

没有答案