# Dynamically loaded image using XML won't show

**URL:** <https://forum.kirupa.com/t/dynamically-loaded-image-using-xml-wont-show/271795>\
**Category:** flash\
**Created:** [September 28, 2008, 8:25pm UTC](https://forum.kirupa.com/t/dynamically-loaded-image-using-xml-wont-show/271795 "2008-09-28T20:25:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christiang](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@christiang](https://forum.kirupa.com/u/christiang)\
**Post date:** [September 28, 2008, 8:25pm UTC](https://forum.kirupa.com/t/dynamically-loaded-image-using-xml-wont-show/271795/1 "2008-09-28T20:25:01Z")

</div>

Hi,

I need help. I think I’m going blind, to make sure I wonder if anyone else can find an error in the following code.

In short, the .swf gets a list of imagenames in XML format, parses that then proceeds to load the first image in the list. Only thing is, nothing happens. See results below.

```auto

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var imageLoader:Loader;
var imageList:XMLList;
var imagePosition:int = 0;
var totalNumberOfImages:int = 0;

var showImage:MovieClip = new MovieClip();
showImage.width = 750;
showImage.height = 450;
showImage.x = 0;
showImage.y = 0;
addChild(showImage);

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("http://localhost/sydpol/GetImageListAsXML.php"));

function LoadXML(e:Event):void {
	xmlData = new XML(e.target.data);
	imageList = xmlData.children();
	trace(imageList);
	SwapImage();
}

function SwapImage():void {
	if(imagePosition > totalNumberOfImages){
		imagePosition = 0;
	}	
	
	var url:String = imageList[imagePosition].@src;
	trace(url);
	trace("http://localhost/sydpol/" + url);
	imageLoader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoaded);
	imageLoader.load(new URLRequest("http://localhost/sydpol/" + url));	
	
	imagePosition++;
}

function ImageLoaded(e:Event):void {
	showImage.addChild(this.imageLoader);
	trace("Image is loaded");
}

```

Trace result:  
\<image src=“images/1.jpg”/\>  
\<image src=“images/2.jpg”/\>  
\<image src=“images/3.jpg”/\>  
\<image src=“images/4.jpg”/\>  
\<image src=“images/5.jpg”/\>  
\<image src=“images/6.jpg”/\>  
images/1.jpg  
[http://localhost/sydpol/images/1.jpg](http://localhost/sydpol/images/1.jpg)  
Image is loaded

Actual result:  
No fri#¤in image.

Thanks!
