Method of loading text to SWF file in XML document in Flash

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.