# Set the position of images using XML file

**URL:** <https://forum.kirupa.com/t/set-the-position-of-images-using-xml-file/230444>\
**Category:** flash\
**Created:** [June 26, 2007, 10:32am UTC](https://forum.kirupa.com/t/set-the-position-of-images-using-xml-file/230444 "2007-06-26T10:32:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamna](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jamna](https://forum.kirupa.com/u/jamna)\
**Post date:** [June 26, 2007, 10:32am UTC](https://forum.kirupa.com/t/set-the-position-of-images-using-xml-file/230444/1 "2007-06-26T10:32:33Z")

</div>

Hello everybody,

I got sucessfully images in flash file from a XML for this type of work i wrote this code::

var theXml:XML = new XML();  
theXml.ignoreWhite = true;  
theXml.onLoad = function() {  
var i;  
var numofnode = theXml.firstChild.childNodes.length;  
for (i=0; i\<numofnode; i++)  
{  
\_root.createEmptyMovieClip(“imageholder”+i,i);  
\_root[“imageholder”+i].loadMovie(this.firstChild.childNodes\*.attributes.main);  
}  
};  
//… …  
theXml.load(“image.xml”);  
//… …

and my xml is like this:

\<?xml version=“1.0” ?\>  
\<Product\>  
\<image main=“ImgCollection/1182599809XYZL\_pointing\_finger.gif” main1=“This is image 1” /\>  
\<image main=“ImgCollection/1182600605XYZimini-samples.gif” main1=“This is image 2” /\>  
\<image main=“ImgCollection/1182601399XYZ16-003.jpg” main1=“Flowers” /\>  
\<image main=“ImgCollection/1182752928XYZ42-15217086.jpg” main1=“Make up” /\>  
\</Product\>

but the problem is that all images are overlapping to eachother and i know there is some properties like .\_x and .\_y in flash for adjust the position of images .  
but can anyone tell me that how can I exactly do this?

I again try this and wrote this code like:

var theXml:XML = new XML();  
theXml.ignoreWhite = true;  
theXml.onLoad = function() {  
var i;  
var numofnode = theXml.firstChild.childNodes.length;  
\_root.yval = 0;  
for (i=0; i\<numofnode; i++)  
{  
\_root.createEmptyMovieClip(“imageholder”+i,i);  
\_root[“imageholder”+i].loadMovie(this.firstChild.childNodes\*.attributes.main);  
\_root[“imageholder”+i].\_y = \_root.yval;  
\_root.yval = \_root[“imageholder”+i].\_y +\_root[“imageholder”+i].\_height ;  
}  
};  
//… …  
theXml.load(“image.xml”);  
//… …

but it doesn’t work as i wish mean i want my images like this

image1 image2

image3 image4

image5 image6

image7 image…n

and so on .

so I can got my image one by one from left to right.

If anybody can.
