So i tried modifying the xml gallery code a bit to include thumbnails that load up dynamically. Here is the code i’m using, not that much of it has changed except the loadXml function:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
thumb = [];
total = xmlNode.childNodes.length;
var spacing:Number = 28.4;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
thumb* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
var name = "thumb" + i;
var y:Number = i * spacing;
thumbs_mc.attachMovie("thumb", name, i);
thumbs_mc[name]._y = y;
thumbs_mc[name].loadMovie(thumb*);
thumbs_mc[name].onRelease = function() {
picture.loadMovie(image*);
};
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("venue.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);
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" OF "+total;
}
here is my XML file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>galleries/venue/interior1.jpg</image>
<thumb>galleries/venue/thumbs/interior1t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior2.jpg</image>
<thumb>galleries/venue/thumbs/interior2t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior3.jpg</image>
<thumb>galleries/venue/thumbs/interior3t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior4.jpg</image>
<thumb>galleries/venue/thumbs/interior4t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior5.jpg</image>
<thumb>galleries/venue/thumbs/interior5t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior6.jpg</image>
<thumb>galleries/venue/thumbs/interior6t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior7.jpg</image>
<thumb>galleries/venue/thumbs/interior7t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior8.jpg</image>
<thumb>galleries/venue/thumbs/interior8t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior9.jpg</image>
<thumb>galleries/venue/thumbs/interior9t.jpg</thumb>
</pic>
<pic>
<image>galleries/venue/interior10.jpg</image>
<thumb>galleries/venue/thumbs/interior10t.jpg</thumb>
</pic>
</images>
so the problem is that the thumbs load up and line up, but i cant get them to click and load the bigger image on release (the on release statement doesnt even do anything, it doesnt let me click the thumbs). i tried making another movie clip on top of it that houses invisible buttons through code, which made it clickable but it still wouldnt load the images properly in the container. i have everything set up correctly and i’ve tested a couple of ways to do all of this, but nothing seems to be working. i need the thumbnail to load up the corresponding image and also update the 1 OF 10 (or whatever it is) display and correspond with the prev/next buttons (i think that may not need to be changed if written properly).
also, the preloader is set up correctly but only shows it preloading like 10% and then the image loads (when u use the prev/next buttons, cuz thats the only way it works). i’m kind of at a loss here because this is only my second time trying to do stuff with xml/flash.
any help would be greatly appreciated as i need to get this thing out the door asap. thanks in advance to anyone who helsp out.