# XML photo gallery with prev/next buttons

**URL:** <https://forum.kirupa.com/t/xml-photo-gallery-with-prev-next-buttons/279948>\
**Category:** flash\
**Created:** [January 20, 2009, 11:03pm UTC](https://forum.kirupa.com/t/xml-photo-gallery-with-prev-next-buttons/279948 "2009-01-20T23:03:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rainy](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Rainy](https://forum.kirupa.com/u/Rainy)\
**Post date:** [January 20, 2009, 11:03pm UTC](https://forum.kirupa.com/t/xml-photo-gallery-with-prev-next-buttons/279948/1 "2009-01-20T23:03:16Z")

</div>

Hi,

I am trying to make an xml photo gallery for so many days but constantly getting errors, don’t understand why? Please help me…

Here is the XML file:

```php
<images>
    <pic>
        <img>thumb_winter</img>
        <captions>Winter</captions>
    </pic>
    <pic>
        <img>blue_hill</img>
        <captions>Blue Hill</captions>
    </pic>
</images>  

```

And here is the AS 3.0 code:

```php

import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;

var list:XMLList= new XMLList();
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("images.xml");

loader.load(req);
loader.addEventListener(Event.COMPLETE, onComplete);

function onComplete(ev:Event):void
{
    try {
        if(loader != null)
        {
            var loader:URLLoader = URLLoader(ev.target.data);
            var result:XML = new XML(loader.data);
            var data_xml:XMLDocument = new XMLDocument();
            data_xml.ignoreWhite = true;
            var node:XMLNode = data_xml.firstChild;
            text_txt.text = node.firstChild.attributes['captions']; //added for testing
            this.addChild(text_txt);
        }
        else {
            trace("File not loaded");
        }
    }
    catch(error:Error)
    {
        trace("Error Encountered");
    }
}  

```

When I run this code…it catches the error & shows “Error Encountered”. If I remove try…catch statements…it shows

```php
to flash.net.URLLoader.
    at photo_fla::MainTimeline/onComplete()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()  

```

I am writing this on main timeline & not making .as file.

Also, how can I show a photo on stage using pic\_mc (a movieclip)…I am badly confused because of errors & all.

P.S.  
On stage I have:

1. pic\_mc (a movie clip…Picture holder)
2. Previous & next buttons (to navigate through pictures)
3. text\_txt ( a dynamic text box to show picture description)
4. pos\_txt ( a dynamic text box to show picture number i.e. 2 out of 10)
