# Image loading w/XML

**URL:** https://forum.kirupa.com/t/image-loading-w-xml/263572
**Category:** flash
**Created:** [June 17, 2008, 10:44am UTC](https://forum.kirupa.com/t/image-loading-w-xml/263572 "2008-06-17T10:44:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)
#### Post date: [June 17, 2008, 10:44am UTC](https://forum.kirupa.com/t/image-loading-w-xml/263572/1 "2008-06-17T10:44:53Z")

</div>

Hello. I’m trying to figure out how to use XML to load images on a movie clip. This is what I have so far…  
\*\*  
This is my xml structure: \*\*  
\<root\>\<picThumb\>images/picThumb1.png\</picThumb\>  
\<picThumb\>images/picThumb2.png\</picThumb\>  
…  
…  
\</root\>

\*\* AS3 code structure: \*\*  
var myXML:XML= new XML();  
var myURL:URLRequest= new URLRequest(“pictures.xml”);  
var myLoader:URLLoader= new URLLoader(myURL);  
myLoader.addEventListener(Event.COMPLETE, loadXML);

function loadXML(externalxml:Event):void {  
myXML.ignoreComments=true;  
myXML.ignoreWhitespace=true;  
myXML=new XML(externalxml.target.data);  
parseXML(myXML);  
}

function parseXML(flashxml:XML):void {  
showContent(flashxml);  
}

function showContent(parsedxml:XML) {  
var myXLIST:XMLLIST= parsedxml.children();  
var allthumbs:MovieClip= new MovieClip();  
allthumbs.name= “allthumbs”;  
addChildAt(allthumbs, 0);

//I’m stuck here. How can I use XML to load  
//pictures into “allthumbs” with a for loop?

}

---

<div class="post-metadata">

### Author: ![GfO](https://avatars.discourse-cdn.com/v4/letter/g/e56c9b/32.png) [@GfO](https://forum.kirupa.com/u/GfO)
#### Post date: [June 17, 2008, 11:21am UTC](https://forum.kirupa.com/t/image-loading-w-xml/263572/2 "2008-06-17T11:21:38Z")

</div>

Seems like you’re right on track. All you have to do is to run through a for each loop, like this for example;

```auto
for each(var picThumb in myXLIST){
	var img = picThumb;
	var _loader:Loader = new Loader();
    	var request:URLRequest = new URLRequest(img);
   	_loader.load(request);
		
	var thisThumb:MovieClip = new MovieClip();
	allthumbs.addChild(thisThumb);
	thisThumb.addChild(_loader);
}

```

I usually create a movieclip for each of the images, so that I can attach names and attributes to them individually.

Good luck!
