Friday, September 12, 2008

**UPDATE** *NEW* XMLLoader Class v. 1.8

**Update**
XMLLoader 2.0 « Cleck Here

**UPDATE**
Build 1.8 had some back end updates.


  • Complete Event doesn't dispatch early

  • XML Root is now passed instead of just the children




Syntax is still the same

As many of you may already know, I built an XMLLoader class couple months ago. I have steadily been adding more features and making it more robust and easier to use. In this release v.1.6, 2 new features are introduced. You can now choose which list to get by the name of the xml file and now there is a new function to load xml outside of the constructor.


Here is an example of calling a list by ts name instead of the array number.


import com.clementegomez.utils.XMLLoader;

var testXML:XMLLoader = new XMLLoader();

testXML.loadXML(["test.xml", "test2.xml", "test.xml", "test2.xml"]);

testXML.addEventListener(Event.COMPLETE, doIT);

function doIT(e:Event)
{
var list:XMLList;
list = testXML.getList["test2.xml"];
trace(list);
}





The getList property returns an array, so to reference a list by its name you place the name within the [ ] brackets. Simple enough. You can still reference lists by there array number if this is more convenient for you.

The second new feature is the loadXML function. This basically does what the constructor did in previous versions. In the above code you can see how it is used. This is if you rather not load up your xml files in constructor. This can also be useful to define the XMLLoader and load your xml files later on in your script.

I hope you find this useful. Enjoy and like always suggestions and bug reporting is welcome.

Download XMLLoader Class Here

No comments:

Post a Comment