Starting Simple: Handling XML with AS3
There are a few tutorials in line - and I don't know if I ever get them ready to be published. So I decided to start in small pieces. This piece is one of the fundamentals: Loading and parsing XML in Actionscript 3. (I assume you are familiar with OOP and classes in AS3)... We are going to read in a simple XML -file. Create one and name it "playlist.xml". This is how it looks like: Now, in Flash the IDE (or whatever you like), open the actions-panel and put in that code: // import the needed classes import flash.net.URLLoader; import flash.net.URLRequest; // create a loader object var loader:URLLoader = new URLLoader(); // get xml-url via URL-request var xmlURL = new URLRequest('playlist.xml'); // now add an event-listener to wait for XML to be loaded - then call the function "parseXML" loader.addEventListener(Event.COMPLETE, parseXML); // okay, action -> load the thing! loader.load(xmlURL); // this function is executed when the xml has loaded function parseXML(e:Event):void { // now we do whatever we want to do var _xml:XML = new XML(e.target.data); trace(_xml); // EXAMPLE: use the "image" in a XMLList var myList:XMLList = new XMLList(_xml.image); // now pick the url of the 2nd element (for use in loops or whatever) someTextField.txt = myList[1]@url; } […]