Create a new Flash document and save it as a xmlreviews.fla.
Add the following code to frame 1th in the timeline: This.createtextfield ("My_txt", 10, 10, 10, 320, 100);
The code is as follows |
Copy Code |
My_ Txt.autosize = "Left"; My_txt.border = true; My_txt.multiline = true; My_txt.wordwrap = true; var reviews_xml:xml = new XML (); Reviews_xml.ignorewhite = true; Reviews_xml.onload = function (Success:boolean): Void { if (success) { var childitems:array = reviews_xml.firstChild.childNodes; for (var i:number = 0; i < childitems.length; i++) { &NBSP;&NBSP;&N bsp; My_txt.text + + Childitems[i].firstchild.firstchild.nodevalue + "n"; } } else { my_txt.text = "Unable to load external fil E. "; } } Reviews_xml.load ("/reviews.xml"); |
The first code block in the code snippet above will create a new text field on the stage. This text field is used to display parts of an XML document that is loaded later. The second code block is responsible for creating an XML object that will be used to load the XML content. When the date is fully loaded and analyzed by Flash, the Xml.onload () event handler is called immediately and the contents of the XML package are displayed in the Text field.
Save the Flash document and select Control > Test movie to test the SWF file.
Flash displays the following output in the text field on the stage:
Item 1
Item 2
...
Item 8