How to Load Data and Use it From XML
This article has been added to your 'Articles to Read' list.

Create the FLA
Victor Gaudioso
Victor Gaudioso is a Sr. Application developer for an advertising firm in Hollywood, CA. He specializes in Flash / ActionScirpt but also programs in other languages including but not limited to C#, XAML, WPF and ASP .NET. He has engineered Flash sites for the major entertainment studios including Disney, Universal, TouchStone, Mattel and Warner Bros. among others. Victor is known as dvlnblk in the http://actionscript.org forums and has recently been appointed a site moderator. AIM: dvlnblk2004 Yahoo: victoratdeadline
View all articles by Victor Gaudioso
Then create an AS layer and paste in this code:
// create the XML variable
var xml:XML = new XML();
// you must ignore whitespace
xml.ignoreWhite = true;
// the function that is called when the xml is loaded
xml.onLoad = function() {
// tells you the number of child nodes
var nodes = this.firstChild.childNodes;
// tells you how many items you have
numOfItems = nodes.length;
// attach icons
for (var i = 0; i<numOfItems; i++) {
// attach image to the myImageHolder MovieClip
myImageHolder.loadMovie(nodes[i].attributes.image);
// set the text
myText.text = nodes[i].attributes.caption;
}
};
// load the xml
xml.load("xml/images.xml");
If you run this you will see that the content is now populated from the xml page.

Simple as that.
Spread The Word
Attachments
14 Responses to "How to Load Data and Use it From XML" 
|
said this on 14 Mar 2007 12:58:18 PM CST
I've always found thi
{ for( { }; |
|
said this on 09 Apr 2007 4:37:44 AM CST
it's better to check
obj.onLoad i } else { } // p } } |
|
said this on 11 May 2007 6:21:43 AM CST
Works only for jpg. Faile
|
|
said this on 13 Jun 2007 12:03:23 PM CST
I'm an extremely new
What i -Thanks |
|
said this on 17 Jun 2007 4:23:32 PM CST
I was disappointed that t
"What I assume & |
|
said this on 09 Jul 2007 8:17:03 PM CST
How can I change the imag
|
|
said this on 12 Jul 2007 4:52:00 AM CST
I keep getting an error r
1120: Access of and a second for |
|
said this on 12 Jul 2007 8:32:04 AM CST
Weirdly the downloaded zi
|
|
said this on 07 Aug 2007 6:09:15 PM CST
Had a similar error and c
|
|
said this on 03 Oct 2007 10:55:05 AM CST
I would like some further
|
|
said this on 03 Dec 2007 10:17:50 PM CST
Thank you. This was very
Than |
|
said this on 23 Nov 2008 7:27:48 PM CST
David G...An AS layer is
|



Author/Admin)