dragon

Loading Multiple SWF files with LoaderMax Cause RAM Issue! LoaderMax Bug???

Recommended Posts

Hi all...

Based on one of your Great Codes I developed this one : It is all about 4 SWF files that will be load one after another then it stores last swf you ran when you close it ( when you exit each one it will be load next time exactly the same SWF you've exited). for example if you close swf number 3 , next time you start the main swf you will start from SWF number 3...

 

But there is a big problem here ...

Each of my SFWs are about 10 to 16 Mb (I didn't create them with flash) and unfortunately your code seem to load all of them at once ... then play them in sequence ... I have to load more than 100 SWF files and it will definitely cause RAM issue ... Each one cost me 10-16MB...

 

I'm not a programmer but I'm thinking why showing multiple SWF files and remembering where you left is that hard in 2018 ??? ...

  

Please Help me find a way to load swfs one after another and save last status of it ...

You're My Last Hope Carl ...

Thanks


 

import flash.events.FullScreenEvent;
import flash.display.StageScaleMode;

stage.scaleMode = StageScaleMode.SHOW_ALL;
stage.displayState = StageDisplayState.FULL_SCREEN;
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.SharedObject;

import flash.events.MouseEvent;


var mySO:SharedObject = SharedObject.getLocal("edfiujy6grwfh");
var reza:Number = -1;
var loaderIndex:Number = -1;

loaderIndex = mySO.data.my_vis;
if (!mySO.data.my_vis) {
loaderIndex = -1;
}


if (mySO.data.my_vis == 1) {
loaderIndex = 0;
}


if (mySO.data.my_vis == 2) {
loaderIndex = 1;
}

if (mySO.data.my_vis == 3) {
loaderIndex = 2;
}

if (mySO.data.my_vis == 4) {
loaderIndex = 3;
}

progress_mc.scaleX = 0;


var currentLoader:SWFLoader;


var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler});


swfs.append(new SWFLoader("part1.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part2.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part3.swf", {container:this.stage, autoPlay:false}));
swfs.append(new SWFLoader("part4.swf", {container:this.stage, 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++;
    trace(loaderIndex);
    
    reza = loaderIndex
    trace(reza);

    mySO.data.my_vis = loaderIndex;
    mySO.flush ();


if (loaderIndex == swfs.numChildren) {
//reset back to 0 if the last swf has already played
//loaderIndex  =  0;


        //can't show stuff that was unloaded so lets stop 

      mySO.clear();
     loaderIndex = -1
     swfs.load();
trace("all done everyone gone");
removeEventListener(Event.ENTER_FRAME, trackSWFPlayback);


} else {
//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;


    //fade it in 


TweenLite.from(currentLoader.content, 0.1, {alpha:1});


//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();

//unload the swf that just played 
        
currentLoader.unload();
        
//set up and play the next swf


initCurrentLoader();


}
}

this.addEventListener(Event.ENTER_FRAME, loadSWFs)

function loadSWFs(e:Event):void{
load_btn.visible = false;
swfs.load();
this.removeEventListener(Event.ENTER_FRAME, loadSWFs)

}
/* Click to Hide an Object
Clicking on the specified symbol instance hides it.

Instructions:
1. Use this code for objects that are currently visible.
*/

 

Share this post


Link to post
Share on other sites

Sorry, but this isn't the type of thing we support anymore. It would take far too long to assess the problem and suggest a proper fix to handle memory management like this. The code you are referencing was certainly not intended for 100 swfs. I think your best route forward will be to hire a programmer that is proficient in these things. Wish I had better news for you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.