Jump to content
Search Community

Progress Up and Down

baldscone test
Moderator Tag

Recommended Posts

Hi - Im trying to load a few XML files and images plus the main SWF in a FlashDevelop project but I keep getting some strange behaviour where the progress reports this (please note this is running from harddrive but same behaviour occurs online)

progress: 0.5724668064290706

progress: 0.2862334032145353

progress: 0.1908222688096902

progress: 0.1908222688096902

progress: 0.23852783601211275

progress: 0.25

progress: 0.49743709226467847

progress: 0.498564015053027

progress: 0.5011720627430418

progress: 0.525034226125457

progress: 0.5410815455644398

progress: 0.5649437089468549

progress: 0.8124299076850252

progress: 0.8149437089468549

progress: 0.829905623279591

progress: 0.8537677866620061

progress: 0.8742335532543948

progress: 0.8980957166368099

progress: 0.9219578800192249

progress: 0.9255115713432662

progress: 0.9493737347256812

progress: 0.9579881592170227

progress: 0.9818503225994378

progress: 1

LoaderMax 'mainQueue' is complete!

 

I can only think that the initial 57% reading is the SWF file and then it somehow excludes that when loading the rest - really not sure - have tried disabling defaultAuditSize but doesnt help.

Any ideas? Here is my code - its inside a class file so I pass through a reference to the main preloader displayObject to use SelfLoader:

 

_loadQueue = new LoaderMax(config);

_loadQueue.append( new SelfLoader(targetDispObj) ); //Include the root swf in the progress calculations (this)

 

//Prepend path to content

_loadQueue.prependURLs(_basePath, false);

 

//we know the XML contains ImageLoader, so we need to activate those classes once in the swf so that the XMLLoader can recognize them.

LoaderMax.activate([imageLoader]);

 

//append two XML loaders necessary

_loadQueue.append( new XMLLoader(Settings.SETTINGS_URL, { name:"settingsXML", prependURLs:_basePath } ) );

_loadQueue.append( new XMLLoader(Settings.JOB_FEED_URL, { name:"jobfeedXML", prependURLs:_basePath } ) );

_loadQueue.append( new XMLLoader(Settings.CONTENT_URL, { name:"contentXML", prependURLs:_basePath } ) );

 

//prioritize the XML settings load so we get images asap

LoaderMax.prioritize("settings");

 

_loadQueue.load();

 

private function progressHandler(event:LoaderEvent):void {

//Get percentage as 0-1.0

_percentLoaded = event.target.progress;

}

Link to comment
Share on other sites

Sounds like expected behavior that explained here:

http://www.greensock.com/loadermax-tips/#9

 

It's impossible for LoaderMax to know the size of all your nested loaders inside the XML files unless/until it reads the XML and either parses the estimatedBytes you define there or audits each loading file's size. I noticed you didn't set an estimatedBytes on your XMLLoaders either. I'd recommend setting those as though they include the subloading files too (like if your XML has 50000 bytes worth of nodes, make sure your XMLLoader's estimatedBytes is 50000 + the size of the raw XML).

 

Does that clear things up for you?

Link to comment
Share on other sites

Hi - thanks for the reply. I didn't set the estimatedBytes in the code but I did in my XML file - this is the correct syntax below right?

I thought that it might be because of that - is there anyway I can stop the progress event dispatching until it knows how big it is? i.e. is there an event like LoaderEvent.AUDIT_COMPLETE which I can listen for and then start displaying the progress information?

 

Ceiling

0,0,0

 

Ive added this too - is it right to define both in XML and code?

var totalImageBytes:uint = 683391;//<--- UPDATE THESE FIGURES

var xmlSettingsFileBytes:uint = 3235;

var settingsBytes:uint = totalImageBytes + xmlSettingsFileBytes;

var jobFeedBytes:uint = 1342;

var contentBytes:uint = 5072;

 

_loadQueue.append( new XMLLoader(Settings.SETTINGS_URL, { name:"settingsXML", prependURLs:_basePath, estimatedBytes:settingsBytes } ) );

_loadQueue.append( new XMLLoader(Settings.JOB_FEED_URL, { name:"jobfeedXML", prependURLs:_basePath, estimatedBytes:jobFeedBytes } ) );

_loadQueue.append( new XMLLoader(Settings.CONTENT_URL, { name:"contentXML", prependURLs:_basePath, estimatedBytes:contentBytes } ) );

Link to comment
Share on other sites

You can't prevent ProgressEvents from being dispatched, but you certainly can wait to add your listener until the XMLLoader dispatches its INIT event, meaning it has loaded and parsed the XML. Like:

 

var loader:XMLLoader = new XMLLoader("data.xml", {onInit:initHandler});
loader.load();

function initHandler(event:LoaderEvent):void {
   trace("xml loaded: " + event.target.content);
   event.target.addEventListener(LoaderEvent.PROGRESS, progressHandler);
}

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

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