all groups > flash actionscript > may 2006 >
You're in the

flash actionscript

group:

XML Slideshow Buttons, Help!


XML Slideshow Buttons, Help! Xodus6.com
5/14/2006 8:57:45 PM
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);
}
}
Re: XML Slideshow Buttons, Help! fanmap81
5/14/2006 11:13:27 PM
Re: XML Slideshow Buttons, Help! Xodus6.com
5/15/2006 12:00:00 AM
I've tried looking that over, I can't seem to incorporate the buttons still...
basically, I can't tell what's wrong because when I place the button code into
the main code, there are no errors when I publish the file, but when I try it
out, the buttons simply do not work... any suggestions?
Re: XML Slideshow Buttons, Help! Xodus6.com
5/15/2006 6:28:21 PM
I think the problem is implementing:

function slideShow() {
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
updateSlide(firstSlideNode);
currentSlideNode = firstSlideNode;
} else {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}

...into the main script....

function slideShow() {
if (currentIndex == totalSlides-1) { currentIndex = 0; } else {
currentIndex++; }
targetPhoto._visible = false;
targetWidth=thumbs; // get width
targetHeight=thumbs; // get height;
updateSlide();
}


I've tried updating it several ways and it never seems to work... Once I
figure how to update the two together, i can simply add the button code and it
should work...
AddThis Social Bookmark Button