0.1 prepare external files: create a folder on your hard disk and put a list of image list files in the file list. xml in the following format:
<? Xml version = "1.0" encoding = "GB2312"?> <Images> <I s = "images/v82008.jpg" a = "images_abbr/v82008.jpg"> not broadcast Super Girl contest </I> <I s = "images/060820110116v82009.jpg" a =" "images_abbr/movie"> eat "cheapest lunch box" </I> <I s = "images/movie" a = "images_abbr/060820110131v82010.jpg"> Our reporter experienced "Super Girl voice" in Changsha" background </I> </images>
Place the image file according to the path here.
PS: In fact, the name is not clear, but at the beginning I considered the transmission time, the xml file was compressed in the variable.
0.2 create a new Flash file. The file size is set to 300*225 (reference) and saved as picsExchange. fla. The file is in the same directory as list. xml.
1.1 start reading and analyzing XML, and store all the information in the array. Here, the author creates three arrays: descriptions, imgabbrs, and imgs.
1.2 add code to the first frame:
Stop (); // because it is a timeline version, you must stop playing the video before entering the second timeline after reading and analyzing xml.
System. useCodepage = true // prevents Chinese garbled characters
Var imgList: XML = new XML () // create an object for reading xml
ImgList. load ("list. xml") // read the list. xml file.
Var descriptions: Array
Var imgabbrs: Array
Var imgs: Array // defines three arrays for storing image information
Var imgsNum: Number = 0; // variable for placing the Number of images
ImgList. onLoad = function (success ){
ImgList. ignoreWhite = true
If (success ){
Descriptions = new Array ()
Imgabbrs = new Array ()
Imgs = new Array () // This step is used to initialize the Array. When you re-read the Array, clear the content.
ImgsNum = imgList. childNodes [0]. childNodes. length
For (var I in imgList. childNodes [0]. childNodes ){
Var imgNode: XMLNode = imgList. childNodes [0]. childNodes
Descriptions= ImgNode. childNodes [0]. nodeValue // This is the text description of the image.
Trace ("description:" + descriptions)
Imgabbrs = imgNode. attributes. a // This is the path of the thumbnail.
Trace ("imgabbr:" + imgabbrs)
Imgs = imgNode. attributes. s // This is the path of the source image.
Trace ("img:" + imgs)
}
Play (); // after analysis, the timeline can be played.
} Else {
Trace ("loading error! ")
}
}