I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3. Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.
**** Code in AS3 (I need help in writing equivalent code in AS2) :-
var xmlText:XML ;
var xmlReq:URLRequest = new URLRequest("myFile.xml");
var xmlLoader:URLLoader = new URLLoader();
xmlText = new XML(xmlLoader.data);
info_txt.htmlText = xmlText.someTag ;
**** I cannot use the above as is because, when I change the publish settings from AS3 to AS2, I get following errors -
The class or interface 'URLRequest' could not be loaded.
The class or interface 'URLLoader' could not be loaded.
The class or interface 'Event' could not be loaded.
Same works well in AS3. What should I do to make this work in AS2 or can anyone direct me in writing an equivalent in AS2.
Thanks in advance.
Yup. Those classes don't exist in AS2. But there is the XML class. In some ways, much simpler in AS2. So just check out it's section in the help documents.
var xmlText:XML = new XML();
Of course there might be other bits like ignorWhite and your onLoad handler....
Of course the parsing of the XMLnodes and all isn't as easy or great in AS2 as it is in AS3...I think....
Can you direct me to any website where i can get a sample of this. I am not able to write As2. and will this "new XML" code work for any type of source ? I will eventually be calling a Java Servlet which returns an XML object. so I dont really have an XML file but need to request the servlet