# Photo Gallery with XML and Flash : second thumbnail area

**URL:** <https://forum.kirupa.com/t/photo-gallery-with-xml-and-flash-second-thumbnail-area/215268>\
**Category:** flash\
**Created:** [February 5, 2007, 10:53pm UTC](https://forum.kirupa.com/t/photo-gallery-with-xml-and-flash-second-thumbnail-area/215268 "2007-02-05T22:53:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxykav](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@foxykav](https://forum.kirupa.com/u/foxykav)\
**Post date:** [February 5, 2007, 10:53pm UTC](https://forum.kirupa.com/t/photo-gallery-with-xml-and-flash-second-thumbnail-area/215268/1 "2007-02-05T22:53:58Z")

</div>

I’m trying to get two thumbnail movieclips on the same page to display two different arrays of pictures. It’s not working though and I’m not sure why, could someone please look at my xml and ActionScript and see what I’m doingwrong. I’ve been at this for a few hours now and I can’t see whats wrong. Please help!

XML:

\<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
\<images\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 1\</name\>  
\<description\>Body Suit 1 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs1.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs1.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs1.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs1.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 2\</name\>  
\<description\>Body Suit 2 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs2.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs2.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs2.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs2.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 3\</name\>  
\<description\>Body Suit 3 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs3.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs3.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs3.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs3.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 4\</name\>  
\<description\>Body Suit 4 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs4.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs4.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs4.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs4.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 5\</name\>  
\<description\>Body Suit 5 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs5.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs5.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs5.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs5.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 6\</name\>  
\<description\>Body Suit 6 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs6.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs6.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs6.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs6.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 7\</name\>  
\<description\>Body Suit 7 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs7.jpg\</mainimage\>  
\<mainthumb\>photos/bodysuit/small/bs7.jpg\</mainthumb\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs7.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs7.jpg\</otherthumbs\>  
\</pic\>  
\<pic\>  
\<category\>Bodysuit\</category\>  
\<name\>Body Suit 8\</name\>  
\<description\>Body Suit 8 description.\</description\>  
\<mainimage\>photos/bodysuit/large/bs8.jpg\</mainimage\>  
\<thumbnail\>photos/bodysuit/small/bs8.jpg\</thumbnail\>  
\<price\>$00.00\</price\>  
\<sizes\>0 - 0\</sizes\>  
\<otherimages\>photos/bodysuit/large/bs8.jpg\</otherimages\>  
\<otherthumbs\>photos/bodysuit/small/bs8.jpg\</otherthumbs\>  
\</pic\>  
\</images\>

ActionScript:

function loadXML(loaded) {

```
if (loaded) {
    
    xmlNode = this.firstChild;
    category = [];
    title = [];
    image = [];
    description = [];
    thumbnails = [];
    price = [];
    sizes = [];
    otherimages = [];
    otherthumbs = [];
    total = xmlNode.childNodes.length;
    
    for (i=0; i&lt;total; i++) {
        category* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
        title* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
        description* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
        image* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
        thumbnails* = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
        thumbnails_fn(i);
        price* = xmlNode.childNodes*.childNodes[5].firstChild.nodeValue;
        sizes* = xmlNode.childNodes*.childNodes[6].firstChild.nodeValue;
        otherimages* = xmlNode.childNodes*.childNodes[7].firstChild.nodeValue;
        //otherimages_fn(i);
        otherthumbs* = xmlNode.childNodes*.childNodes[8].firstChild.nodeValue;
        otherthumbs_fn(i);
    }
    
    firstImage();
    
} else {
    
    content = "file not loaded!";
    
}

```

}

xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images2.xml”);

/////////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};

Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};

next\_btn.onRelease = function() {  
nextImage();  
};

/////////////////////////////////////  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (picture.\_alpha\<100) {  
picture.\_alpha += 10;  
}  
}

};

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
price\_txt.text = price[p];  
sizes\_txt.text = sizes[p];  
title\_txt.text = title[p];  
picture\_num();

```
    }
}

```

}

function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
price\_txt.text = price[p];  
sizes\_txt.text = sizes[p];  
title\_txt.text = title[p];  
picture\_num();  
}  
}

function firstImage() {  
if (loaded == filesize){  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
price\_txt.text = price[0];  
sizes\_txt.text = sizes[0];  
title\_txt.text = title[0];  
picture\_num();

```
}

```

}

function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}

function thumbNailScroller() {  
// thumbnail code!  
this.createEmptyMovieClip(“tscroller”, 1000);  
scroll\_speed = 10;  
tscroller.onEnterFrame = function() {  
if ((\_root.\_ymouse\>=thumbnail\_mc.\_y) && (\_root.\_ymouse\<=thumbnail\_mc.\_y+thumbnail\_mc.\_height)) {  
if ((\_root.\_xmouse\>=(hit\_right.\_x-40)) && (thumbnail\_mc.hitTest(hit\_right))) {  
thumbnail\_mc.\_x -= scroll\_speed;  
} else if ((\_root.\_xmouse\<=(hit\_left.\_x+40)) && (thumbnail\_mc.hitTest(hit\_left))) {  
thumbnail\_mc.\_x += scroll\_speed;  
}  
} else {  
delete tscroller.onEnterFrame;  
}  
};  
}

function thumbnails\_fn(k) {  
thumbnail\_mc.createEmptyMovieClip(“t”+k, thumbnail\_mc.getNextHighestDepth());  
tlistener = new Object();  
tlistener.onLoadInit = function(target\_mc) {  
target\_mc.\_x = hit\_left.\_x+(target\_mc.\_width+5)\*k;  
target\_mc.pictureValue = k;  
target\_mc.onRelease = function() {  
p = this.pictureValue-1;  
nextImage();  
};

```
    target_mc.onRollOver = function() {
        this._alpha = 50;
        thumbNailScroller();
    };
    
    target_mc.onRollOut = function() {
        this._alpha = 100;
    };
    
};

image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);

```

}

function otherthumbs\_fn(l) {  
thumbnail\_mc1.createEmptyMovieClip(“s”+l, thumbnail\_mc1.getNextHighestDepth());  
slistener = new Object();  
slistener.onLoadInit = function(target\_mc\_1) {  
target\_mc\_1.\_x = hit\_left1.\_x+(target\_mc\_1.\_width+5)\*l;  
target\_mc\_1.pictureValue = l;  
target\_mc\_1.onRelease = function() {  
p = this.pictureValue-1;  
nextImage();  
};

```
    target_mc_1.onRollOver = function() {
        this._alpha = 50;
        // thumbNailScroller();
    };
    
    target_mc_1.onRollOut = function() {
        this._alpha = 100;
    };
    
};

image_mcl_1 = new MovieClipLoader();
image_mcl_1.addListener(slistener);
image_mcl_1.loadClip(otherthumbs[l], "thumbnail_mc1.s"+l);

```

}

If you can help that would be great!
