flash actionscript:
Hello! I'm an amateur when it comes to actionscript and I'm trying to modify
an existing script that I found from Flash Kit to include a backwards and
forwards button. It seems so simple and yet when i try to modify it, the
buttons don't work. Here is the script for the slideshow (it is an XML based
dynamic slideshow).
// (c) Copyright by Andrew DiFiore. All rights reserved. DO NOT REMOVE.
fscommand("allowscale", "false");
Stage.scaleMode = "noScale";
targetPhoto._visible = false;
slides_xml = new XML();
slides_xml.onLoad = loadSlideShow;
slides_xml.load("slideshow_1925_1936.xml");
slides_xml.ignoreWhite = true;
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);
tx = 60;
for (i=0; i < totalSlides; i++) { // populate arrays and create thumbnails
dynamically
photos = currentSlideNode.attributes.jpegURL;
thumbs = ;
captions = currentSlideNode.firstChild.nodeValue;
_root.attachMovie("thumb","thumb"+i,i);
_root._x = tx;
_root._y = 1595; // using fixed Y coord
_root.tindex = i;
tx += 25;
currentSlideNode = currentSlideNode.nextSibling;
}
// initialize values
currentIndex = 0;
targetWidth=thumbs; // get width
targetHeight=thumbs; // get height;
updateSlide();
}
}
function updateSlide() { // load photo, update caption and status fields
targetPhoto.loadPhoto(photos);
caption = captions;
statusField = (currentIndex+1) + "/" + totalSlides;
}
function slideShow() {
if (currentIndex == totalSlides-1) { currentIndex = 0; } else {
currentIndex++; }
targetPhoto._visible = false;
targetWidth=thumbs; // get width
targetHeight=thumbs; // get height;
updateSlide();
}
MovieClip.prototype.loadPhoto = function(fn) { // load external jpeg method +
preloader
this.createEmptyMovieClip("holder", 1);
this.holder.loadMovie(fn);
this.onEnterFrame = function() { // NOTE: could use this to display
percentage to user
if
(Math.floor((this.holder.getBytesLoaded()/this.holder.getBytesTotal())*100) >=
100) {
delete this.onEnterFrame;
}
}
}
An older version of the script has a forward and backwards button, but the
current version does not (the animation for the second version is much better
and thus why I want to implement this instead of reverting back). This is what
was used for the first version:
nextBtn.onRelease = function() { // event handler for next button
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
break;
} else {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
prevBtn.onRelease = function() { // event handler for prev button
previousSlideNode = currentSlideNode.previousSibling;
if (previousSlideNode == null) {
break;
} else {
currentIndex--;
currentSlideNode = previousSlideNode;
updateSlide(previousSlideNode);
}
}
Could someone please help?? Seems like a easy solution. Thank you.
nextBtn.onRelease = function() { // event handler for next button
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
break;
} else {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
prevBtn.onRelease = function() { // event handler for prev button
previousSlideNode = currentSlideNode.previousSibling;
if (previousSlideNode == null) {
break;
} else {
currentIndex--;
currentSlideNode = previousSlideNode;
updateSlide(previousSlideNode);
}
}