Reputation:
I found this project uploaded named loadSWFsPlaySequence dot zip ... but unfortunately I faced a big problem : problem : as I want to load huge and multiple swfs one after another I should be aware of memory that loaded swfs take ,so I tried to unload last swf when new swf is loading but each time I failed ... please somebody tell me am I such stupid or it's hard to ... can you help ? thanks a lot ... link to that file :
in this project we have 4 swf file named part1.swf and part2.swf and ... part4.swf .it uses LoaderMax to load 4 swf files and play them in sequence. When a swf reaches it's last frame it tells the next swf to play. it works fine , but when new swf is loading last one just stop and doesn't unload . I want to unload last loaded swf when new swf is loading ... here is the code (link to main fla file is here click to download : http://greensock.com/forums/index.php?app=core&module=attach§ion=attach&attach_id=2074 )
here is the code
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();
}
Upvotes: 0
Views: 105