# XML Photo Gallery with Thumbs and Dynamic Resize issue

**URL:** https://forum.kirupa.com/t/xml-photo-gallery-with-thumbs-and-dynamic-resize-issue/185936
**Category:** flash
**Created:** [April 17, 2006, 8:28pm UTC](https://forum.kirupa.com/t/xml-photo-gallery-with-thumbs-and-dynamic-resize-issue/185936 "2006-04-17T20:28:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![speakvolume](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@speakvolume](https://forum.kirupa.com/u/speakvolume)
#### Post date: [April 17, 2006, 8:28pm UTC](https://forum.kirupa.com/t/xml-photo-gallery-with-thumbs-and-dynamic-resize-issue/185936/1 "2006-04-17T20:28:51Z")

</div>

I’m looking for some advice on a incorporating thumbs to my photo gallery, and am having some problems making them work. My photos need to be resized dynamically as they are different sizes and this is working beautifully but I can’t for all that’s holy get the thumbs to work as they do so well in the “adding thumbnails” tutorial. Would love any assistance.

Thanks so much…

here’s the code…maybe this may help piece together the problem.

FLASH ::

title\_txt.htmlText = “\<font color=”#000000"\>Title: \</font\>\<font color="#FFFFFF"\>Splash Screen\</font\>";  
/\* Debug Variables \*/  
//debug = 1; //Comment this “debug” line to stop the movie from ‘tracing’ or ‘outputting’  
holderMC.\_alpha = 0;  
var picArray = new Array();  
var tempArray = new Array();  
var thumbNailArray = new Array();  
var SPACING = 10;  
var DEPTH = 0;  
var xmlFILE = “gallery.xml”;

function printer(str)  
{  
// If debug flag is set, output different operation in the movie  
debug ? trace(str) : null;  
}

MovieClip.prototype.loadPic = function(pic)  
{  
picnum\_txt.text = (pic+1) + “/” + NUMOFPICS; // Add one to the ‘pic’ var since an array starts at 0  
printer(“STATUS: Loading Picture " + pic);  
holderMC.\_alpha = 0;  
cur = pic;  
if (pathToPICS.length \> 1)  
{  
this.loadMovie(pathToPICS+picArray[pic]);  
}  
else  
{  
this.loadMovie(picArray[pic]);  
}  
this.\_parent.onEnterFrame = function()  
{  
var t = holderMC.getBytesTotal(), l = holderMC.getBytesLoaded();  
if (t != 0 && Math.round(l/t) == 1 && holderMC.\_width\>0)  
{  
var w = holderMC.\_width+SPACING, h = holderMC.\_height+SPACING;  
border.resizePic(w, h, pic);  
delete this.\_parent.onEnterFrame;  
}  
};  
};  
MovieClip.prototype.resizePic = function(w, h, pic)  
{  
var speed = 3;  
holderMC.\_alpha = 0;  
this.onEnterFrame = function()  
{  
this.\_width += (w-this.\_width)/speed;  
this.\_height += (h-this.\_height)/speed;  
title\_txt.htmlText = “\<font color=”#000000”\>\<b\>Currently Viewing:\</b\>\</font\>&nbsp;" + “\<font color=”#FFFFFF"\>" + tempArray[pic] + “\</font\>”;  
if (Math.abs(this.\_width-w)\<1 && Math.abs(this.\_height-h)\<1)  
{  
this.\_width = w;  
this.\_height = h;  
holderMC.\_x = this.\_x-this.\_width/2+SPACING/2;  
holderMC.\_y = this.\_y-this.\_height/2+SPACING/2;  
holderMC.\_alpha += 5;  
if (holderMC.\_alpha\>90)  
{  
holderMC.\_alpha = 100;  
delete this.onEnterFrame;  
}  
}  
};  
};

var gallery\_xml = new XML();  
gallery\_xml.ignoreWhite = true;  
gallery\_xml.onLoad = function(success)  
{  
if (success)  
{  
printer(“RESULT: XML File Loaded!”);  
var gallery = this.firstChild;  
pathToPICS = gallery.attributes.picturePath;  
NUMOFPICS = gallery.childNodes.length;  
printer(“Number of Pics: '” + NUMOFPICS + “’”);  
printer(“Path to Pics: '” + pathToPICS + “’”);  
for (var i = 0; i\<NUMOFPICS; i++)  
{  
tempArray.push(gallery.childNodes\*.attributes.title);  
picArray.push(gallery.childNodes\*.attributes.source);  
thumbNailArray.push(gallery.childNodes\*.attributes.thumbNail);  
thumbnails\_fn(i);  
}  
//loading first picture  
holderMC.loadPic(0);

```
    // Button Code
    prev.onRelease = function() 
        {
        if (cur == 0) 
            {
            /* Uncomment this line if you want the pictures to start over after it reaches the first image in the array */
            //holderMC.loadPic(picArray.length-1);
            }
        else
            {
            holderMC.loadPic(cur-1);
            }
        };
    next.onRelease = function()
        {
        if (cur == picArray.length-1) 
            {
            /* Uncomment this line if you want the pictures to start over after it reaches the last image in the array */
            //holderMC.loadPic(0);
            } 
        else
            {
            holderMC.loadPic(cur+1);
            }
        };
    } 
else 
    {
    printer("ERROR: XML File NOT Loaded '" + xmlFILE +" '");
    }
};

```

gallery\_xml.load(xmlFILE); // Load the xml file  
printer("XML File: " + xmlFILE);

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\<=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+(eval(“thumbnail\_mc.t”+k).\_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(thumbnail[k], “thumbnail\_mc.t”+k);

}

XML ::

\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<gallery picturePath=“exhibitdesign/” \>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“001\_shaw\_center002.jpg” thumbnail=“th0.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“002\_shaw\_center001.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“003\_shaw\_center005.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“004\_shaw\_center019.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“005\_shaw\_center021.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“006\_shaw\_center004.jpg”/\>  
\<image title=“EXHIBIT DESIGN Shaw Center for the Arts Baton Rouge, LA” source=“007\_shaw\_center010.jpg”/\>  
\</gallery\>

\<!–  
Exif Info  
–\>

Thanks in advance.
