# XML & AS3 Help Needed

**URL:** <https://forum.kirupa.com/t/xml-as3-help-needed/294600>\
**Category:** flash\
**Created:** [August 17, 2009, 12:21pm UTC](https://forum.kirupa.com/t/xml-as3-help-needed/294600 "2009-08-17T12:21:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danhodkinson](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danhodkinson](https://forum.kirupa.com/u/danhodkinson)\
**Post date:** [August 17, 2009, 12:21pm UTC](https://forum.kirupa.com/t/xml-as3-help-needed/294600/1 "2009-08-17T12:21:52Z")

</div>

Hi there,

I am having a small problem bringing in XML to show thumbnails of projects… each thumbnail then needs to have a next and previous button to scroll through the images for the project.

I have got it to show one project (which cycles through all of the images in the XML) but i need to separate it out to show the first image of each project as a separate thumbnail.

here are the main workings of my code:

```php
function processXML(e:Event):void {
    myXML = new XML(e.target.data);
    loadXML();
}

function loadXML():void
    {
    picsList = myXML.images.image;
    trace(picsList);
    pictureLoader.load(new URLRequest(picsList[counter].attribute("source")));
}
    
function animate():void
{
    pictureLoader.load(new URLRequest(picsList[counter].attribute("source")));
    TweenLite.to(pictureLoader, 1, {alpha:1});
    trace(counter);
}
function nextButton(event:MouseEvent):void
{   
    if (this.counter < this.myXML.images.image.length()-1)
    {
    this.counter = this.counter + 1;
    }
    else
    {
        counter = 0
    }
    TweenLite.to(pictureLoader, 1, {alpha:0, onComplete:animate});
} 

function prevButton(event:MouseEvent):void
{   
    if (this.counter <= 0)
    {
        this.counter = this.myXML.images.image.length()-1
    }
    else
    {
        this.counter = this.counter -1;
    }
    TweenLite.to(pictureLoader, 1, {alpha:0, onComplete:animate});
}

```

and my xml file is laid out like so:

```php
<projects>
<images>
<image source= "thumbs/thumb2.jpg" text="one"></image>
<image source= "thumbs/thumb3.jpg" text="one"></image>
<image source= "thumbs/thumb4.jpg" text="one"></image>
</images>

<images>
<image source= "thumbs/thumb5.jpg" text="one"></image>
<image source= "thumbs/thumb6.jpg" text="one"></image>
</images>

</projects>

```

i presume it will need a for each loop for each images element, but i cant quite crack the code yet.  
Any help or advice is much appreciated

Regards  
Dan
