Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetInterval - Resetting the Interval

Status
Not open for further replies.

FlashN00b

IS-IT--Management
Jul 7, 2008
4
US
The issue I have after I change the image, the setInterval timer does not reset itself. 5 second delay starts, but when a new image is loaded, the 5 second delay does not reset.

Code
----------------------------------------------
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
setInterval(timer,5000);
}
}

function timer(){
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
updateSlide(rootNode.firstChild);
currentSlideNode = rootNode.firstChild;
} else {
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}

function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
loadMovie(imagePath, targetClip);
}

next_btn.onRelease = function() {
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
updateSlide(rootNode.firstChild);
currentSlideNode = rootNode.firstChild;
} else {
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
};

back_btn.onRelease = function() {
previousSlideNode = currentSlideNode.previousSibling;
if (previousSlideNode == null) {
currentSlideNode = rootNode.lastChild;
updateSlide(rootNode.lastChild);
} else {
currentSlideNode = previousSlideNode;
updateSlide(previousSlideNode);
}
};
 
var intID:Number;

function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
intID = setInterval(timer,5000);
}
}

function timer(){
clearInterval(intID);
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
updateSlide(rootNode.firstChild);
currentSlideNode = rootNode.firstChild;
} else {
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}

Regards. FLASH HELP - OPENED FOR BUSINESS!
TO GET YOUR OWN FREE WEBSITE HOSTING
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top