**Update**
http://blog.kreativeking.com/2008/10/xmlloader-20-updatexmlloader-20-update/
I have been working hard on making this as robust and stable as possible. This release should be able to do anything you would like with loading XML. Couple of new features from 1.8 the community has been emailing me about as well as some that I wanted to include in past versions. I will be releasing a video tutorial on how to use this class properly. I'll explain the new features to hold you over until then.
New Constructor
XMLLoader($url:Array = null, $cache:Boolean = false):void
In 2.0, the XMLLoader constructor now takes 2 parameters. The first, being the same as in past versions, an Array of the xml files being loaded. The second being a new feature called cacheBuster which I will get more into bit later. By default these are set to null and false respectively.
New Cachebuster Feature
XmlLoader 2.0 introduces the new Cachebuster feature. This feature allows you to always load up an up to date version of your XML File. This is will make it so your flash application will not used cached files. This parameter is takes a boolean value and can be set in two ways. One being in the constructor shown above. The second is by setting the cacheBuster property.
XMLLoader.cacheBuster = true;
XMLLoader.cacheBuster =false;
New way of referencing load XML's
In past versions, to access a certain loaded XML file. Something like the code below would be used.
XMLLoader.getList["xmlfile.xml"];
In 2.0 the file extension is no longer accepted, just the name of the file like below.
XMLLoader.getList["xmlfile"];
Also in 2.0, if you have two loaded files that happen to have the same name. To access the other files after the first. You only need to put the name + underscore + array index. Here is an example.
var testXML:XMLLoader = new XMLLoader(["test.xml", "test2.xml", "test.xml", "test2.xml", "test.xml", "test2.xml"], true);
testXML.addEventListener(Event.COMPLETE, doIT);
function doIT(e:Event)
{
var list:XML;
list = testXML.getList["test_4"];
trace(list);
}
In the above code, the last test.xml will be loaded. The array index is its spot in the url array.
Those are the main new features in 2.0. Some other under the hood work includes some better error catching and proper event dispatching. The video tutorial should be out before the month is out as well as a new ite to host them, so look out for that. As always, let me know of any bugs and suggestions nd I will try to get to them ASAP.
Enjoy
[...] **Update** XMLLoader 2.0 « Cleck Here [...]
ReplyDelete[...] **Update** XMLLoader 2.0 « Cleck Here [...]
ReplyDelete[...] **Update** XMLLoader 2.0 « Cleck Here [...]
ReplyDeleteI received a host of errors when i exported the .fla check your coding again.
ReplyDeleteDo you happen to have the .fla of your file? The class is working fine. There is probably a small error.
ReplyDeletehello I recieve the error 1046: Type was not found or was not a compile-time constant: ParamEvent from the example fla, what could be happened. Thank you!
ReplyDeleteMy mistake, I forgot to include that in the download. Just redownload and everything should be fine. Sorry for the confusion =D
ReplyDelete@clemente G
ReplyDeletehello! thanks you for the update. Now I recieve the error
Error: Loading Failed
at com.clementegomez.utils::XMLLoader/onError()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
Thank you in advance.
Ah, This happens when your xml path is incorrect. Check your path to see if its correct. Post your code also and I can help you debug.
ReplyDeleteI 'm using your own attached examples. The only thing I've done is that I've moved the com folder inside the examples path and opened the *.flas.
ReplyDeleteHmm It should be working fine. I just tested the files and they seem to be working for me. Are you copying the whole com folder or its contents to the folder with the FLA. Also you might want to check your classpath settings.
ReplyDeleteAH you know what, its probably the path. If you are on a PC, you will most likely need to reverse the backslashes.
ReplyDeleteThank you very much for your support. My OS is Windows Vista, I receive the same error even when I'm trying to load only test.xml (but anyway folder1/test.xml is also the same for Vista) I've moved the whole com folder where the fla is. My settings in the classpath are empty and the default (publish settings>flash>settings>classpath list).
ReplyDeleteOk now it works fine. The problem had to do with the cachebuster. I should turn it off for working locally. Very powerful and simple in syntax class indeed. Perchaps in your examples the cachebuster should be off. Thank you so much!
ReplyDelete[...] would be an understatement. I completely forgot that I submitted an article to FFD introducing my XMLLoader Class. Its a very good article and tutorial and I suggest anyone t check it out. Another well known [...]
ReplyDeleteand wath about retrive attributes from nodes?
ReplyDeleteThis would be achieved the same way as an XML file.
ReplyDeleteXMLLoader.getList["xmlfile"].attribute("atrribute_name");