Jump to content
Search Community

XMLLoader with ImageLoader childs

Garthd test
Moderator Tag

Recommended Posts

Hi,

 

im trying to get used to this awesome loader tool and had my problems in the beginning which i was able to solve alone. But now im stuck and have no clue how to debug and solve this problem.

 

i have an xml with imageloader childs to load some images automaticaly. the xml looks something like this:

 

<?xml version="1.0" encoding="utf-8"?>




  .
  .
  .


 

now im loading this in my .as with:

 

_xmlLdr = new XMLLoader("loadData.xml", {name:"xmlDoc", requireWithRoot:this.root, onComplete:parseXML, onError:ioErrorHandler});
_xmlLdr.load();

 

everything worked as long i only had like 5 items in my xml but now the file got bigger, there are more images to load and since then it gives me errors because after the xml-completehandler i'll try to use the "loaded" images. but they are not all loaded. so i can narrow down the problem. i know its a timing problem. i know im trying to work with not loaded images. but i dont know how to check if they are loaded or not. i thought the xml-completehandler will be called once all the childs are loaded and not once the xml itself is loaded. can someone help me?

 

yeah, my english is bad but i still hope that i could explain the problem.

Link to comment
Share on other sites

hmmm, that's very strange. There is no reason why adding more images would make it break. And as you expect that onComplete should only fire after the xml AND all the images are completely loaded.

 

Is there a particular image that consistantly fails to load or do you know where the images stop loading?

 

does the ioError ever fire? Do you only get errors when you try to access images after onComplete fires?

 

 

 

Can you verify that the xml is fully loading and it is the version you expect? When testing in browsers sometimes the xml gets cached and you don't always get your recently saved version.

 

Moving forward:

 

First, make sure you are using the latest version of LoaderMax.

 

Second, Find the breaking point. How many images makes it break? What image makes it break? just remove nodes in your xml until it works again.

 

I really doubt the size of your xml/number of images has anything to do with it.

 

Third, if you can't narrow it down any further feel free to post your files or something as simple as possible that we can work with that demonstrates the error

 

seeing what is happening in the onComplete or whatever function that "targets the images that aren't loaded"

 

-carl

Link to comment
Share on other sites

Hi,

 

ok, the problem is solved. there is no problem with the xml-loader but still it was something which was affacted by the xml getting more childs to load. i had a second loader (actually first) which is doing stuff onComplete and everything worked fine as long the xml was loaded before this one. but since the xml got longer it took a while to load and the first loader started to produce some errors. still i dont understand why the XML loader isnt added to the root.loader. i use this code:

 

 LoaderMax.activate([xmlLoader,ImageLoader]);

		_ldrQueue = new LoaderMax({name:"mainQueue", requireWithRoot:this.root, autoLoad:true, onProgress:updatePreloader, onComplete:onLoadedBg, onError:ioErrorHandler});
		_ldrQueue.append( new SWFLoader("bg_home.swf", {name:"home", estimatedBytes:300000, container:mc_bg_container, autoPlay:true, autoDispose:true}) );
		_xmlLdr = new XMLLoader("loadData.xml", {name:"xmlDoc", requireWithRoot:this.root, onComplete:parseXML, onError:ioErrorHandler});
		_xmlLdr.load();

 

 

thx in advance

Link to comment
Share on other sites

i'm glad your problem is solved. what you added after that is a bit confusing though.

 

are you loading the swf that contains the code you posted into another swf? requireWithRoot just means that loaders that you create in the current file will be calculated into the load progress of a parent swf. no where do you mention another swf, so I don't know what to advise here.

 

if you need one loader to load after another, make sure the second loader doesn't load until the onComplete of the first loader has fired.

 

you might do something like this

 

function onLoadedBg(e:LoaderEvent):void{
xmlLdr.load();
}

Link to comment
Share on other sites

Hi,

 

yes i actually have a preloader.swf which loads the main.swf. the code belongs to the main swf and i want to achieve that the background and xml (and all its content) is loaded before my movie continues. i hope this makes it understandable...sry

Link to comment
Share on other sites

so you have a preloader swf that loads main.swf

main.swf loads XML

XML loads images

main.swf also loads a bg swf

 

it is unclear to me what preloader swf is doing. is that where you are tracking the total load of everything?

 

 

in order to get main.swf sorted try putting _xmlLdr inside _ldrQueue.

 

then _ldrQueue will be able to track the total progress of all the subloaders and report back to preloader.swf

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