# Getting current image / total images in XML

**URL:** <https://forum.kirupa.com/t/getting-current-image-total-images-in-xml/272090>\
**Category:** flash\
**Created:** [October 1, 2008, 10:53pm UTC](https://forum.kirupa.com/t/getting-current-image-total-images-in-xml/272090 "2008-10-01T22:53:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rundevo](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@Rundevo](https://forum.kirupa.com/u/Rundevo)\
**Post date:** [October 1, 2008, 10:53pm UTC](https://forum.kirupa.com/t/getting-current-image-total-images-in-xml/272090/1 "2008-10-01T22:53:32Z")

</div>

Having abit of a struggle here to get the current image in the XMLList that my mouse is rolling over!

My XML looks like this with afew more item tags.

```auto
<items>
	<item>
		<name>a name</name>
		<image source="http://www.domain.com/images/image0.jpg" thumb="http://www.domain.com/thumbs/image0.jpg">description</image>
		<image source="http://www.domain.com/images/image1.jpg" thumb="http://www.domain.com/thumbs/image1.jpg">description</image>
		<image source="http://www.domain.com/images/image2.jpg" thumb="http://www.domain.com/thumbs/image2.jpg">description</image>
		<image source="http://www.domain.com/images/image3.jpg" thumb="http://www.domain.com/thumbs/image3.jpg">description</image>
	</item>
<items>

```

and my AS3 looks like this

```auto
function xmlLoaded(event:Event):void
{
	xml = XML(event.target.data);
	images = xml.item.image;

	for (var i:int=0; i < imagesToLoad; i++)
	{
		startLoader=new Loader();
		startLoader.load(new URLRequest(images[_randomArr*].attribute("thumb")));
		startLoader.name=images[_randomArr*].attribute("source");
		addChild(startLoader);
		startLoader.addEventListener(MouseEvent.CLICK, showPicture);
		startLoader.addEventListener(MouseEvent.ROLL_OVER, showInfo);
		startLoader.addEventListener(MouseEvent.ROLL_OUT, removeInfo);
	}
	function showPicture(event:MouseEvent):void
	{
		imageLoader=new Loader();
		imageLoader.load(new URLRequest(event.target.name));
		addChild(imageLoader);
	}
	function showInfo(event:MouseEvent):void
	{
		imageText.x = event.target.x;
		imageText.y = event.target.y;

		for (var j:int = 0; j < images.length(); j++)
		{
			if (images[j].attribute("source") == event.target.name)
			{
				imageText.text = images.@source[j].parent().parent().name;
			}
		}
		addChild(imageText);

		imageNumber.x = event.target.x;
		imageNumber.y = event.target.y;

		for (var k:int = 0; k < images.length(); k++)
		{
			if (images[k].attribute("source") == event.target.name)
			{
				imageNumber.text = [k+1] + " / " + images.@source[k].parent().parent().image.length();
			}
		}
		addChild(imageNumber);
	}
}

```

I managed to get the total number of images but I just dont know how to get the current image. If its 1 out of 4 or 2 out of 4 and so on.

What I´m getting now is the iteration the image has out of all the images in the portfolio, and not the iteration it has in the \<item\> tag.

I should add that all the images are added randomly, which ofcourse, confuses things 🙂

Any help in this matter is, like always, very appreciated!

Regards

/rundevo
