Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
bonassus

progress of all loaders in mainQueue

Recommended Posts

I would like to set up a preloader for the all the loaders from an xml file. i nested all the loaders in a mainQueue loaderMax but this didn't work. the progress jumps arround seemingly reporting the progress of each nested loader. how can i get the progress of all loaders?

 

Thanks!

 

<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<LoaderMax name="mainQueue">  
   <LoaderMax name="queue_MissA" x="540"y="180" scale="1.5" >
	<LoaderMax name="actor1"prependURLs="Casting_MP3s/" load="true">
	<MP3Loader  url="JenTullock_MissA_06.mp3" name="JenTullock_MissA_06" actor="JenTullock"autoPlay="false"/>
   <MP3Loader  url="JenTullock_MissA_07.mp3" name="JenTullock_MissA_07" actor="JenTullock"autoPlay="false"/>
	   </LoaderMax>
	 <LoaderMax name="actor2"prependURLs="Casting_MP3s/" load="true">
	 <MP3Loader  url="JenTullock_MissA_06copy.mp3" name="JenTullock_MissA_06copy"actor="JenTullock"autoPlay="false"/>
	 </LoaderMax>
   </LoaderMax>
 </LoaderMax>

</data>

 

 

LoaderMax.activate([MP3Loader]);
  loader = new XMLLoader("data.xml", {onComplete:completeHandler, onProgress:progressHandler, estimatedBytes:20365992});

  loader.load();

function progressHandler(event:LoaderEvent):void {
  trace("progress: " + event.target.progress);
  var s:int = int(event.target.progress * 100);
  myProgressBar.progressText.text = "progress: " + s.toString() + "%";
  myProgressBar.bar.scaleX = event.target.progress;
 }

Link to comment
Share on other sites

I have read them. when i use rawProgress i get an error:

Property rawProgress not found on com.greensock.loading.XMLLoader

my loaders are defined in the xml file but my progressHandler is reporting for the xml loader

 

loader = new XMLLoader("data.xml", {onComplete:completeHandler, onProgress:progressHandler});

 

i don't understand how to get the progress of loaderMax mainQueue. which would calculate all the loaders as on loader. I'm guessing this is obvious but i'm not seeing it.

 

thanks!

Link to comment
Share on other sites

Right, the rawProgress is only for LoaderMax instances, but XMLLoader actually creates one internally which you can get by appending "_Queue" to the name of your XMLLoader and using LoaderMax.getLoader(), like:

 

var myLoader:XMLLoader = new XMLLoader("data.xml", {name:"data", onInit:initHandler});
var myQueue:LoaderMax; //we'll set this once the XMLLoader has initted (meaning it read the XML)
function initHandler(event:LoaderEvent):void {
   myQueue = LoaderMax.getLoader("data_Queue");
   myQueue.addEventListener(LoaderEvent.PROGRESS, progressHandler);
}
function progressHandler(event:LoaderEvent):void {
   trace("progress: " + myQueue.rawProgress);
}

 

Of course you can get around all this by defining an accurate estimatedBytes for all your loaders in the XML so that LoaderMax doesn't need to do any audits.

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