Jump to content
Search Community

Beginner LoaderMax setup

bdavey311 test
Moderator Tag

Recommended Posts

Greensock!

 

I've implemented the beginning pieces of loaderMax into a template I purchased, that I asked about a few days ago and I think it's good to go. ;)

 

Just a few thing such as whether or not I have it setup correctly. Each swf that loads, has it's own XML file. Do I have to insert code into each swf or does LoaderMax recognize that info while it's loading it in the queue? Not sure I fully understood the documentation explanation. Sorry about that. Trying to wrap my head around it. So taking the sample code from the LoaderMax page this is how I have it setup:

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;

//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});

//append several loaders
queue.append( new SWFLoader("content.swf", {name:"contentClip", estimatedBytes:126000, container:this, visible:false, autoPlay:false}) );
queue.append( new SWFLoader("team.swf", {name:"teamClip", estimatedBytes:129000, container:this, visible:false, autoPlay:false}) );
queue.append( new SWFLoader("news.swf", {name:"newsClip", estimatedBytes:140000, container:this, visible:false, autoPlay:false}) );
queue.append( new SWFLoader("contact.swf", {name:"contactClip", estimatedBytes:70000, container:this, visible:false, autoPlay:false}) );

//start loading
queue.load();

//pause loading
queue.pause();

//resume loading
queue.resume();

function progressHandler(event:LoaderEvent):void {
   trace("progress: " + event.target.progress);
}

function completeHandler(event:LoaderEvent):void {
   trace(event.target + " is complete!");
}

function errorHandler(event:LoaderEvent):void {
   trace("error occured with " + event.target + ": " + event.text);
}

 

I don't want the swf's to show, just be cached so I used the visible property. That right? And to clarify my earlier question about the XML data, should I just put those in the queue here as well? At this point I'm not too concerned about showing a progress bar...maybe that will come later once I get more comfortable with these basic steps. Thanks again for all the help. You rule!

 

bD

Link to comment
Share on other sites

If you just want to cache things (not have them show up on the stage), it's fine to set visible:false, but it'd be even better to just not declare a "container" so that it never adds it to the stage to begin with.

 

As far as the XML goes, I'm really not sure how you have things structured. If each SWF has an XMLLoader or something that's pulling in data on their own, that's fine. You wouldn't need to duplicate loading it in the parent. Just let the child swfs do it. But if you have separate XML that you need to load (which isn't being loaded by the sub-swfs), then yes, you'd need to add it to the queue.

 

Oh, and you have your queue pause() and then resume() - that's pointless. That sample code in the ASDocs was just to show people that those methods are available. You can delete those two lines.

Link to comment
Share on other sites

Ya I went ahead and included all swfs, jpgs, and xml files and it works like a charm - thank you Chrome Developer tool! So from what I understand if I click on a new link it calls the necessary files and readjusts priorities automatically? Then goes back into the queue? Dope!

 

Thanks for this. Now - adding in a preloader. Fairly straight forward? Bring on your demo files!

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...