Jump to content
Search Community

Loader just loads 1 out of 5 assets... why?

SudoPlz test
Moderator Tag

Recommended Posts

Hello, I'm using the Loader as such..

First im loading an xml file from a remote server.

 

 

queue.append( new XMLLoader( Constants.SERVER_XML_FILENAME ,{estimatedBytes:2000}) );
queue.addEventListener(LoaderEvent.COMPLETE, onXMLLoadComplete);
queue.load();
public function onXMLLoadComplete(ev:LoaderEvent):void
{
 trace(ev.currentTarget.content.length)
//length is 1
}

 

which is 1 indeed

 

Right after this I load 3 remote images and 2 local sounds like so

 

 

 

 

queue.empty(true,true)
queue.addEventListener(LoaderEvent.COMPLETE, onSoundLoadComplete);

queue.append(new MP3Loader( Constants.SOUNDS_PATH + "/move1.mp3" , {estimatedBytes:8594, repeat:0, autoPlay: false,autoDispose:true}));

queue.append(new MP3Loader( Constants.SOUNDS_PATH + "/move2.mp3" , {estimatedBytes:8594, repeat:0, autoPlay: false,autoDispose:true}));



queue.append( new ImageLoader( url1 , { estimatedBytes:1000000 , alpha:0, scaleMode:"proportionalInside",autoDispose:true}) );
queue.append( new ImageLoader( url2 , { estimatedBytes:1000000 , alpha:0, scaleMode:"proportionalInside",autoDispose:true}) );
queue.append( new ImageLoader( url3 , { estimatedBytes:1000000 , alpha:0, scaleMode:"proportionalInside",autoDispose:true}) );
queue.load();


public function onSoundLoadComplete(ev:LoaderEvent):void
{
 trace(ev.currentTarget.content.length)
//length should be 5 but is 1
}

 

which is 1 instead of 5...

 

Also if I add event listeners for cancel,error, ioError, httpStatus etc, i get NO errors at all and the on error handlers never run.

 

It is driving me nuts and I can't figure why it ONLY loads 1 out of the 5 assets I need. (It is an Image also, and not a sound which is the first asset)

..

Help plz.

Link to comment
Share on other sites

I think the problem is that you have autoDispose:true set on each loader which essentially destroys the ImageLoader/MP3Loaders as soon as they have loaded and thus they no longer belong in your queue when the queue fires its onComplete.

 

I appreciate that you tried listening for errors, great approach. In addition I would suggest putting an onComplete callback on each of your loaders in your queue like so

 

queue.append( new ImageLoader( url3 , {onComplete:childComplete, estimatedBytes:1000000 , alpha:0, scaleMode:"proportionalInside",autoDispose:true}) );

function childComplete(evt:LoaderEvent): void{
trace("child loader " + evt.target);
}

 

Does that help verify that the assets are loading?

 

Let us know if you need more help. If you could provide a very simple example of the assets not loading, it will help us give you better assistance.

Link to comment
Share on other sites

Thank you very much for your great helpful and kind response..

This was the problem.. (Strangely I've been using auto-dispose :true all this time with no problems untill now. I mistakenly thought what it did was disposing all the queues and the loaded items AFTER the handler had run.

I said it before and I'll say it again.. Your forums, your replies, and your code are GOLDEN each and every time. Thank you very much.

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