# How to convert this (XML image gallery) from AS2 to AS3?

**URL:** <https://forum.kirupa.com/t/how-to-convert-this-xml-image-gallery-from-as2-to-as3/297405>\
**Category:** flash\
**Created:** [October 1, 2009, 2:46pm UTC](https://forum.kirupa.com/t/how-to-convert-this-xml-image-gallery-from-as2-to-as3/297405 "2009-10-01T14:46:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjckls](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjckls](https://forum.kirupa.com/u/fjckls)\
**Post date:** [October 1, 2009, 2:46pm UTC](https://forum.kirupa.com/t/how-to-convert-this-xml-image-gallery-from-as2-to-as3/297405/1 "2009-10-01T14:46:22Z")

</div>

Hi all,  
I found this great tutorial here in kirupa how to create image gallery using XML [http://www.kirupa.com/developer/mx2004/xml\_flash\_photogallery.htm](http://www.kirupa.com/forum/../developer/mx2004/xml_flash_photogallery.htm)  
How to do the same just with AS3?  
I already have my XML loaded, I just don’t know how to load images in sequence from XML using previous and next buttons  
my XML:

```php
<?xml version="1.0" encoding="UTF-8"?>

<gallery>
 
    <image>
        <title>Head full of Sand</title>
        <url>images/float_head.jpg</url>
    </image>
    
    <image>
        <title>Neck Cramp</title>
        <url>images/neck_cramp.jpg</url>
    </image>
    
    <image>
        <title>This is Cool</title>
        <url>images/gaine.jpg</url>
    </image>
    
</gallery>

```

and AS (galleryData is XML):

```php
var loader:Loader = new Loader();
var preloader:MovieClip = new Pro();

preloader.x = stage.stageWidth/2;
preloader.y = stage.stageHeight/2;

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

next_btn.buttonMode = prev_btn.buttonMode =true;

next_btn.addEventListener(MouseEvent.CLICK, onClick);
prev_btn.addEventListener(MouseEvent.CLICK, onClick);

var file_path:String = galleryData.image.url.text();
var imgNum:int = galleryData.image.length();

function onClick(e:MouseEvent):void {
    switch (e.currentTarget) {
        case next_btn :
             // LOAD NEXT IMAGE
            break;

        case prev_btn :
            // LOAD PREVIOUS IMAGE
            break;
    }
}

function loadComplete(e:Event):void {
    removeChild(preloader);
    addChild(loader);
    description.text = galleryData.image[1].title.text();
}

function onProgress(e:Event):void {
    addChild(preloader);
}

```

I guess I need to use some kind of loop to through array of XML elements.

Thank you!
