Jump to content
Search Community

Generic Loader

teugene test
Moderator Tag

Recommended Posts

Hi there, great job on this library, it's exactly the thing I've been waiting/looking for! Just one question: Is there a way I can use a "generic" loader that would accept url of an undetermined file format from another source, then automatically detects what type of file is it and add it in the queue?

 

Let's say for example I have this xml which I can't change:


someSwf.swf
someImg.img

 

After parsing the links, what I want to do is to add the links into the queue without the need to check what type of file it is and use the appropriate Loader. Is there anything to do that in an easy way or do I have to consign myself to do a string manipulation to determine the file first and then assign the suitable loader?

Link to comment
Share on other sites

Many other loaders take the "lazy" approach (that's what they call it, not me) that will automatically attempt to figure out what type of file it is based on the extension (".jpg", ".xml", etc.). This can be convenient but there are several down sides to this approach:

 

1) It forces ALL types of loaders to be compiled in your swf so that they're available just in case you need them. So your project may never need an SWF loader or MP3 loader, etc. but they still must be compiled in your SWF for the logic in the "lazy" loader. In my opinion, this bloats the whole system which isn't good because a loading system should be relatively lightweight in order to get things moving quickly.

 

2) It's virtually impossible to accurately determine the file type if the extension is something like ".php" because you could have a server-side script that spits back any type - an image, an XML file, etc. In those cases, the "lazy" system would break down. You'd have to explicitly define the type anyway.

 

Ultimately I believe it is much cleaner to have the developer choose the appropriate loader for the asset (ImageLoader, SWFLoader, XMLLoader, etc.) and it definitely allows the system to be more lightweight and efficient. It could literally cut the file size in half in many cases.

Link to comment
Share on other sites

I guess that means I have no choice but to explicitly call the right Loaders. The issue I'm facing now is that I can only retrieve links of images, swf, or sounds from XML files that I have little control of it's formatting. In other words, there are other technical requirements to the XML files in such that, I can't use LoaderMax specific nodes. Anyway, thanks again for your reply and your wonderful libraries so far!

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