Rahzizzle
February 22nd, 2009, 12:57 AM
So I am building a PhotoGallery that reads in data from an XML file, jpegURL and thumbURL are the locations of the pictures.
This is my code
function loadSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
currentSlideNode = rootNode.firstChild;
photos = new Array(totalSlides);
thumbs = new Array(totalSlides);
captions = new Array(totalSlides);
thumbnails = new Array(totalSlides);
var currentThumb;
tx = 0;
for (i=0; i < totalSlides; i++) { // populate arrays and create thumbnails dynamically
photos[i] = currentSlideNode.attributes.jpegURL;
thumbs[i] = [currentSlideNode.attributes.jpegWidth,currentSlide Node.attributes.jpegHeight];
thumbnails[i] = currentSlideNode.attributes.thumbURL;
captions[i] = currentSlideNode.firstChild.nodeValue;
this.createEmptyMovieClip("thumb"+i, i);
'Thumbs'
'currentThumb = _root.attachMovie("thumbHolder", "thumb" + i, i);'
_root.attachMovie("thumb" , "thumb"+i, i);
_root["thumb"+i]._x = tx;
_root["thumb"+i]._y = 300; // using fixed Y coord
_root["thumb"+i].width = 85;
_root["thumb"+i].height = 85;
_root["thumb"+i].tindex = i;
_root["thumb"+i].border = 2;
loadMovie(thumbnails[i], "thumb"+i);
_root["thumb"+i].onPress = function() {
currentIndex = i;
updateSlide();
}
_root["thumb"+i].onRollOver = function() {
_root["thumb"+i]._alpha = 40;
}
tx += 90;
currentSlideNode = currentSlideNode.nextSibling;
}
// initialize values
currentIndex = 0;
targetWidth=thumbs[currentIndex][0]; // get width
targetHeight=thumbs[currentIndex][1]; // get height;
updateSlide();
}
}
It works perfect but the only thing that doesn't work is the onPress and onRollOver events for the thumbnails. I have tried moving that statement elsewhere but I am just exhausted from today and don't want to even try anything more. If someone can spot an error right away I'd be very appreciative, thanks
-Aaron DaMaster :confused:
This is my code
function loadSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
currentSlideNode = rootNode.firstChild;
photos = new Array(totalSlides);
thumbs = new Array(totalSlides);
captions = new Array(totalSlides);
thumbnails = new Array(totalSlides);
var currentThumb;
tx = 0;
for (i=0; i < totalSlides; i++) { // populate arrays and create thumbnails dynamically
photos[i] = currentSlideNode.attributes.jpegURL;
thumbs[i] = [currentSlideNode.attributes.jpegWidth,currentSlide Node.attributes.jpegHeight];
thumbnails[i] = currentSlideNode.attributes.thumbURL;
captions[i] = currentSlideNode.firstChild.nodeValue;
this.createEmptyMovieClip("thumb"+i, i);
'Thumbs'
'currentThumb = _root.attachMovie("thumbHolder", "thumb" + i, i);'
_root.attachMovie("thumb" , "thumb"+i, i);
_root["thumb"+i]._x = tx;
_root["thumb"+i]._y = 300; // using fixed Y coord
_root["thumb"+i].width = 85;
_root["thumb"+i].height = 85;
_root["thumb"+i].tindex = i;
_root["thumb"+i].border = 2;
loadMovie(thumbnails[i], "thumb"+i);
_root["thumb"+i].onPress = function() {
currentIndex = i;
updateSlide();
}
_root["thumb"+i].onRollOver = function() {
_root["thumb"+i]._alpha = 40;
}
tx += 90;
currentSlideNode = currentSlideNode.nextSibling;
}
// initialize values
currentIndex = 0;
targetWidth=thumbs[currentIndex][0]; // get width
targetHeight=thumbs[currentIndex][1]; // get height;
updateSlide();
}
}
It works perfect but the only thing that doesn't work is the onPress and onRollOver events for the thumbnails. I have tried moving that statement elsewhere but I am just exhausted from today and don't want to even try anything more. If someone can spot an error right away I'd be very appreciative, thanks
-Aaron DaMaster :confused: