# Loading multiple images from an XML file problem

**URL:** <https://forum.kirupa.com/t/loading-multiple-images-from-an-xml-file-problem/287165>\
**Category:** flash\
**Created:** [April 27, 2009, 2:19pm UTC](https://forum.kirupa.com/t/loading-multiple-images-from-an-xml-file-problem/287165 "2009-04-27T14:19:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wvoets](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wvoets/32/3904_2.png) [@wvoets](https://forum.kirupa.com/u/wvoets)\
**Post date:** [April 27, 2009, 2:19pm UTC](https://forum.kirupa.com/t/loading-multiple-images-from-an-xml-file-problem/287165/1 "2009-04-27T14:19:21Z")

</div>

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:

```auto
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.
