# XML Gallery Help

**URL:** <https://forum.kirupa.com/t/xml-gallery-help/243334>\
**Category:** Uncategorized\
**Created:** [November 5, 2007, 10:28pm UTC](https://forum.kirupa.com/t/xml-gallery-help/243334 "2007-11-05T22:28:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deathbydesignnz](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@deathbydesignnz](https://forum.kirupa.com/u/deathbydesignnz)\
**Post date:** [November 5, 2007, 10:28pm UTC](https://forum.kirupa.com/t/xml-gallery-help/243334/1 "2007-11-05T22:28:04Z")

</div>

Hi, I am using the base code from the XML Gallery tutorial on [kirupa.com](http://kirupa.com).  
I have set it up so it uses a movieclip instance instead of thumbnail images.  
Currently to show the “selected state” of the thumbnail I am placing overmc over the top of the current thumbnail movieclip - This works fine when the clip is selected with the mouse BUT if the gallery is scrolled through using the keyboard I cant get the over state to work on the current thumb…

Heres my code:

stop();  
thumb.\_visible=0;  
overmc.\_visible = 0;  
preloader.\_visible = 0;  
//Function to load XML file  
function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
\_global.total = xmlNode.childNodes.length;  
for (i=0; i\<\_global.total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
thumbnails\_fn(i);  
}  
firstImage();  
delay = setInterval(makeThumbs, 500);  
//thumbnailContent = total number of thumbnails x width of thumbs  
\_global.thumbnailContent = \_global.total \* thumbWidth;  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“blender.xml”);  
//Create function to recieve keypresses  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
//Functions for buttons (not needed in this version)  
Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};  
next\_btn.onRelease = function() {  
nextImage();  
};  
/////////////////////////////////////  
p = 0;  
//on enter frame function loads image into the mainImage movieclip  
this.onEnterFrame = function() {  
filesize = mainImage.getBytesTotal();  
loaded = mainImage.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (mainImage.\_alpha\<100) {  
mainImage.\_alpha += 2;  
}  
}  
};

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
mainImage.\_alpha = 0;  
mainImage.loadMovie(image[p], 1);  
picture\_num();  
setOverState(“th”+p);  
}  
}  
};

function prevImage() {  
if (p\>0) {  
p–;  
mainImage.\_alpha = 0;  
mainImage.loadMovie(image[p], 1);  
mainImage\_num();  
setOverState(“th”+p);  
}  
};  
function firstImage() {  
if (loaded == filesize) {  
mainImage.\_alpha = 0;  
mainImage.loadMovie(image[0], 1);  
mainImage\_num();  
}  
};  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
};  
//Function to set over state on thumbnail  
function setOverState(thumbClip){  
overmc.\_visible = 1;  
thumbClip.\_alpha = 40;  
overmc.swapDepths(10000);  
overmc.\_x = thumbClip.\_x;  
overmc.\_y = thumbClip.\_y-2;  
};  
//Show selected image  
function showImage(d) {  
if (loaded == filesize) {  
mainImage.\_alpha = 0;  
mainImage.loadMovie(image[d]);  
p = d;  
picture\_num();  
}  
};

function makeThumbs() {  
clearInterval(delay);  
//Setup thumbnails for first 28 images  
for (var i = 0; i\<28 && i\<image.length; i++) {  
var thmb = thumb.duplicateMovieClip(“th”+i, getNextHighestDepth());  
thmb.id = i;  
thmb.\_x = thumb.\_x+(i\*12);

```
    thmb.onRollOver = function(){
        this.gotoAndStop(11);
    }
        
    thmb.onRollOut = function(){
        this.gotoAndStop(10);
    }
    
    thmb.onDragOut = function(){
        this.gotoAndStop(10);
    }
    //On release set over movie clip
    thmb.onRelease = function() {
        showImage(this.id);
        setOverState(this);
    };
}
//Setup thumbnails for next 28 images
for (var i = 28; i&lt;image.length; i++) {
    var thmb = thumb.duplicateMovieClip("th"+i, getNextHighestDepth());
    thmb.id = i;
    thmb._x = -326+(i*12);
    thmb._y = 310+14;
    
    thmb.onRollOver = function(){
        this.gotoAndStop(11);
    }
        
    thmb.onRollOut = function(){
        this.gotoAndStop(10);
    }
    
    thmb.onDragOut = function(){
        this.gotoAndStop(10);
    }
    
    //On release set over movie clip
    thmb.onRelease = function() {
        showImage(this.id);        
        setOverState(this);
    };
}

```

};
