Jump to content
Search Community

LoaderMax and managing memory for multi SWFs?

DarkBrainComics test
Moderator Tag

Recommended Posts

I am starting a project and I would like to use LoaderMax to pre-load entire SWF movies that I then playback, and then load the next one and play it. I want to "pre-load" the next one, of course, but my question is this:

 

What is a reasonable way to approach loading 30 SWF files in a row, each being 1 to 3 MB large. If I just queue them all, will they blow up the viewer's browser? Is there a way to manage the memory allocation? Would love code samples. Sorry if this is a newb question.

 

(Each of my SWF vidoes is 1920x1080 high-def and runs from 30 seconds to 5 minutes, depending).

 

Sorta hoping a project similar to this has been done and documented.

Link to comment
Share on other sites

My recommendation would be to leverage the browser's cache and load each asset but then immediately unload() or dispose(true) them as soon as they load (well, at least the ones you don't need right away). That way, it gets them downloaded into the browser's cache at least but they're not all hanging around in memory, wasting resources. Kinda like:

 

var queue:LoaderMax = new LoaderMax({onChildComplete:childCompleteHandler});
queue.append( new SWFLoader(...) );
...
function childCompleteHandler(event:LoaderEvent):void {
   if (iDoNotNeedThisAssetYet) {
       event.target.unload();
   }
}

 

Then you can load() it later again but it'll be much faster because it's coming from the browser's cache.

Link to comment
Share on other sites

Thanks for the tip on cache, I have more fundamental question.

 

I have 4 MovieClips defined on my stage that I want to move around and manage - but load them with SWF content that I use LoaderMax to get. I have it working for one, but I think I missed an important tidbit - instead of loading the Movieclip, it seems to have replaced or ignored it - so later I can't move the SWF around using the name.

 

function SceneQueueCompleteHandler(event:LoaderEvent):void {

var ComicDisplay:ContentDisplay = LoaderMax.getContent("comicClip");

var ComicScene_mc:MovieClip;

ComicScene_mc = getChildByName("SceneCache0_mc') as MovieClip;

ComicScene_mc = ComicDisplay.rawContent;

ComicScene_mc.x = 0;

ComicScene_mc.y = 0;

ComicScene_mc.play();

}

 

The above works, I see the loaded SWF playback, but then I can't do this:

 

SceneCache0_mc.y=800;

 

And I think I'm missing something important - what is the best way to load this SWF into that existing movieclip - and how can I later unload that SWF and load a different one into that same movieclip?

Link to comment
Share on other sites

I think I finally figured out my core problem. I did not understand that I could access LoaderMax objects directly and did not need to futz with containers and whatnot. This looks like it will work for me:

 

I set a name in the load code like:

 

SceneQueue.append( new SWFLoader(ComicSceneSWFURL[myIndex], {name:"SceneLoader_" + SceneCacheToProcess, container:this, x:0, y:1200, z:0, autoPlay:false}) );

SceneQueue.load();

 

 

Then after it is loaded, I can access it and play it via:

 

LoaderMax.getContent("SceneLoader_" + SceneCacheNum).y=0;

LoaderMax.getContent("SceneLoader_" + SceneCacheNum).rawContent.play();

 

 

So, uh, looks like I was just fundamentally not understanding LoaderMax... I'm hopeful this new trick will now let me load up multiple loaders, move them around, play them, then unload them, etc.

Link to comment
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.
×
×
  • Create New...