/ ** * Flash read XML * Author: cowoo * Date: 2004.7.28 * / Here I use a part of my website as an example to explain how to read XML files in Flash: Open Site-> Home-> Home .fla, you must notice that there are two MCs in the middle of Stage. For the convenience of path operation, I will read the XML code directly to these two MCs. Of course, you can also create an empty MC directly, then Stip the code above, but the problem of the path may harary some people.
First look at this XML file structure: XML Version = "1.0" encoding = "gb2312"?> Update1 update> Update2 update> Update3 update > updatelist> The code is as follows, I added a note in the necessary place: OnClipevent (Load) {system.usendepage = true; // 中文 Update_Xml = new xml (); // Declare an XML object Update_Xml.IgnoreWhite = True ; // ignore the blank update_xml.load in XML ("Home / Update.xml"); // Because this file will be loaded into site-> site.swf (that is, the main movie), read XML The path is home / update.xml update_xml.onload = function (SUCCESS) // Start Load XML file {if (success) // If successful, do the following {updateInfo = update_xml.firstchild; // read the coming XML file Firstchild is public (UpdateIst>); delete update_xml; sb1.setscrollTarget (TF1); // Scrollbar after text is refreshed still available SB2.SetScrollTarget (TF2); Sb3.set ScrollTarget (TF3);} else _parent.Update1 = "error loading xml ...";} function publicing (xml_doc) {content = xml_doc.childNodes; // This content is a bit like an array to store Point for (i = 0; i <3; i ) {this ["Update" add (i 1)] = content [i] .firstchild; // update1, etc. is the variable of the dynamic text box in the movie clip. Note Content [i] .firstchild is the text, that is, text is also used as a node}}} Basic job is the case, if I have any questions about this article, please welcome criticism.
-------------------------------------------------- ------------------------------ I last next website is all the files read by XML, I write a comparison tonight. Simple tutorial everyone looks, the source file can go to my website to download. Http://www.cowoo.netsorry, the server has a problem, click below: http://software.hit.edu.cn/home/cowoo/site.rar can pass http: //software.hit. Edu.cn/home/cowoo/index preview.