Hi David,
Thanks for allowing me the opportunity to answer your question,
programming actionscript is always a pleasure. I've attached below
the full code for the frame 1 actions, modified from the Macromedia
exmaple that you mentioned in your question. For reference this
tutorial is available at
http://www.macromedia.com/support/flash/applications/jpeg_slideshow_xml/.
This program will advance a slideshow using a definable time delay
(variable = delayTime) and a definable number of loops (variable =
loopAmount). The solution does not include the event driven functions
that control the next and back buttons, so I've removed these
functions. Instead, the flash builtin function setInterval calls the
advancePicture function every x milliseconds, defined by delayTime.
I've posted the full project at
http://tunebounce.com/answers/400506/jpeg_slideshow_xml.zip If you
have any questions about the code, or require any additional
assistance, don't hesitate to request a clarification.
Sincerely,
andyt-ga
//flash actionscript code from frame 1
//--------------------------------------
delayTime=1000; //delay between each picture advancing in milliseconds
loopAmount= 3; //how many times the pictures will loop, 0 for infinite
counter=1;
//initializes the counter to 1. everytime all the pictures
//have been shown, counter increments
function advancePictures() { // a function to advance the pictures
//trace("count: "+count);
//trace("loop amount: "+loopAmount);
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
//reset slides to beginning and increment the counter
//if loopAmount is 0 (infinite) or if loopAmount is less then the counter
if(loopAmount==0 || counter<loopAmount) {
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
counter++;
}
//if count is more then loopAmount, then stop looping
else {
break;
}
}
else {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
//calls the advancePictures function every 'delayTime' in milliseconds
myTimer = setInterval(advancePictures, delayTime); // calls the
function after 1 second
}
}
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
} |