Jump to content
GreenSock

Philip Bulley

getLoader by XMLNode

Recommended Posts

Hey Jack,

 

I've found myself in a situation a couple of times now where it'd be great to be able to getLoader by the XMLNode which declared it. What do you think about being able to do something like the following:

 

// AS3
LoaderMax.getLoader( myXML..scene.( @id == 'train' )[0].assetList[0].LoaderMax.( @bandwidth="high" )[0] )

// Here's the XML


















 

Here, I'm using simply to group files (so no url present), and would prefer not to give them and subsequently manage name attributes, as in this case they're better identified by being children of scene.( @id == 'train' ). Forgive me if something like this is already possible, but I haven't come across it.

Link to comment
Share on other sites

I was thinking that maybe the easiest way to do this would be for XMLLoader.parseLoaders to actually add the auto generated name attribute (ie. loader23) to any activated XMLNode (, , , etc). Then I could call:

 

LoaderMax.getLoader( myXML..scene.( @id == 'train' )[0].assetList[0].LoaderMax.( @bandwidth="high" )[0].@name )

Link to comment
Share on other sites

Adding that capability to getLoader() isn't ideal because of the cost in terms of performance and kb, but keep in mind that when XMLLoader parses a LoaderMax-related node, it will stick that particular XML node data in the resulting loader's "vars.rawXML" property so you can loop through things and search for a match if you want.

 

var loaders:Array = myXMLLoader.getChildren();
for (var i:int = 0; i     if (myXML == loaders[i].vars.rawXML) {
       //do stuff...
   }
}

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