Welcome to my actionscript snippet library!

Actionscript Snips is a small repository of actionscript code that aims to save developers and designers time when developing a website.  

Load And Parse XML File

XML File:



picture1.jpg
picture 1
picture 1 description


picture2.jpg
picture 2
picture 2 description


picture3.jpg
picture 3
picture 3 description




Actionscript:


var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlLoader.addEventListener(Event.COMPLETE, loadComplete);
xmlLoader.load(new URLRequest("slideshow.xml"));

function loadComplete(e:Event):void {
xmlData = new XML(e.target.data);
for each (var picture:XML in xmlData.picture) {
trace("Url: " + picture.url);
trace("Heading: " + picture.heading);
trace("Description: " + picture.description);
}
}

0 comments:

Post a Comment