Hey All,
I’m facing a problem - pretty sure it’s an easy fix. I’ve searched the forum and found some similar posts but none of them really made it clear to me what to do. So … any help is really appreciated!
I’m trying to load multiple images from an XML file. And all works fine except, when I test my movie, I only see the last loaded picture.
Here’s what I’ve got so far:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var myDateFieldY = 0;
var myPictureY = 0;
xmlLoader.addEventListener(Event.COMPLETE, LoadXml);
xmlLoader.load(new URLRequest("pictures.xml"));
function LoadXml(e:Event):void {
xmlData = new XML(e.target.data);
ParsePictures(xmlData);
}
function ParsePictures(picturesInput:XML):void {
var dateList:XMLList = picturesInput.Table.Caption;
for each (var dateElement:XML in dateList) {
var myDateField:TextField = new TextField();
addChild(myDateField);
myDateField.text = dateElement;
myDateField.width = 250;
myDateField.x = 110;
myDateFieldY = myDateFieldY + 100;
myDateField.y = myDateFieldY;
}
var pictureList:XMLList = picturesInput.Table.imageurl;
for each (var pictureElement:XML in pictureList) {
var pictureLoader:Loader = new Loader();
function loadPicture(url:String):void {
pictureLoader.load(new URLRequest(url));
pictureLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, pictureLoaded);
}
loadPicture(pictureElement);
myPictureY = myPictureY + 100;
function pictureLoaded(e:Event):void {
addChild(pictureLoader);
pictureLoader.x = 0;
pictureLoader.y = myPictureY;
}
}
}
Again, any help is really appreciated! Thanks in advance & cheers, W.