Jump to content
GreenSock

AmandaWarner

Progress Bar for Multiple XMLLoaders within one XML File

Recommended Posts

I'm using LoaderMax to load an XML file that contains additional XMLLoader nodes.

<sections>
  <XMLLoader activity_type="epi_activity" title="Introduction" url="xml/introduction.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Stages of TB" url="xml/definitions_drag_and_drop.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Risk Factors for TB Infection and Disease" url="xml/risk_factors_timeline.xml" load="true"  />
  <XMLLoader activity_type="epi_activity" title="Comparing Risk Factors" url="xml/compare_situations.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Risk Factors Review" url="xml/risk_factors_drag_and_drop.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Addressing Misconceptions" url="xml/misconceptions.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Data Interpretation" url="xml/data_interpretation.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="The Global Picture" url="xml/maps.xml" load="true" />
  <XMLLoader activity_type="epi_activity" title="Conclusion" url="xml/conclusion.xml" load="true" />
</sections>

These xml files then contain ImageLoaders.

 

For example, here is a short snippet from introduction.xml. Each file contains multiple ImageLoaders.

<page>
  <text>Your progress will be saved once you complete each menu item, so if you need to leave and come back to a module at a different time, that’s fine.</text>
  <ImageLoader name="menu" url="images/menu.png" load="true" x="500" y="100" />
</page>

Everything loads as desired. However, I can't seem to make my progress bar not jump. When I trace out the progress, it very consistently starts around .49, followed by .98, and then drops to .05. It then continues to be pretty jerky throughout the load.

 
I've read the tips and tricks for using LoaderMax. I've tried using rawProgress instead of progress, and I have the same result. I've also tried adding/omitting estimatedBytes, but I always still get the initial jump to .48 and then .98.  

 

Here is my AS for the loader:

public function Main() {
			
  addChild(loadingAssetsView);

  LoaderMax.activate([ImageLoader]);
  queue = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:XMLLoaded});
  queue.append(new XMLLoader(menuXMLURL, {name:"module"}));
  queue.load();
						
  navigationView.addEventListener(Event.CHANGE, loadMenu);

}
		
private function progressHandler(event:LoaderEvent):void {
  loadingAssetsView.progressBar.progressBar.scaleX = event.target.progress;
  loadingAssetsView.textField.text = Math.round(100*(event.target.progress)) + "%";
			
  trace(event.target.progress);
}

Is it initially reporting progress for just the top level XMLLoader? Is there any way to get the loader to report progress for all the loaders in both the top level XML and the referenced XML files at once?

 

Thank you in advance for any suggestions!

  • Like 1
Link to comment
Share on other sites

The fundamental problem is simply that there's no way for LoaderMax to know what's inside those XML files or what files are referenced there, how big they are, etc. That's where the estimatedBytes can come in handy - did you set the estimatedBytes on ALL of your loaders, particularly your XMLLoaders? With all the nesting, even rawProgress would have some jumping merely because it can't even know how many items it has to load - it can keep discovering more and more as it loads those XML files and sub-XML files, etc. See what I mean?

Link to comment
Share on other sites

Thanks so much for your response. 

 

When I was setting estimatedBytes before, I was accounting for just the size of the xml files themselves for the top level XMLLoaders. After reading your message, I've made these numbers much larger to account for all the images that will be referenced within these files so that the initial estimate isn't so completely off. Not perfect, but it at least seems to have resolved the initial jumping backwards problem.

 

Thanks for your help!

Link to comment
Share on other sites

  • 3 weeks later...

Always thought LoaderMax should have a reporting mode, or complementary reporting class that spits out this kind of info for you. You just set up your files, tell it to load them, then when done it dumps the correct AS calls, XML (as above, but with sizes), or probably best - a standalone map of URL:KB sizes - for LoaderMax to reference next time.

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