PDA

View Full Version : xml slideshow using setInterval with varriable time sequence...


grindstonemedia
12-17-2003, 04:54 PM
aahhh okay here it is.....


the problem is that i cannot get setInterval to work with a varriable timer.....


here is the code:



stop();
// create slideGlobals object to store global vars
_global.slideGlobals = new Object();
// create and object to store all xml data
slideShow = new Object();
// create time array inside slideShow object to store time
slideShow.displayTime = new Array();
// create file name array inside slideShow object to store file name
slideShow.fileName = new Array();
// build xml object
mov_xml = new XML();
// fix scope issues with xml object...
mov_xml._tl = this;
mov_xml.onLoad = function(valid) {
if (!valid) {
trace("ERROR ____> xml data not loaded correctly, or data is invalid");
} else {
trace("SUCCESS____> xml loaded successfully");
// get the maximum amount of slides to be loaded
slideGlobals.maxSlides = this._tl.mov_xml.firstChild.childNodes.length;
for (i=0; i<slideGlobals.maxSlides; i++) {
this._tl.slideShow.displayTime.push(this.firstChil d.childNodes[i].attributes.time);
this._tl.slideShow.fileName.push(this.firstChild.c hildNodes[i].attributes.url);
}
// create empty movie clip
this._tl.createEmptyMovieClip("slideMov", 10);
}
// start currentSlide var at zero
currentSlide = 0;
// create the loadMovie function
slideLoad = function () {
trace("slideLoad function called!");
if (currentSlide>=slideGlobals.maxSlides) {
clearInterval(slideInterval);
currentSlide = 0;
// load the movie into the slideMov
slideMov.loadMovie(slideShow.fileName[currentSlide]);
// set the interval as to wich movies should be loaded when
slideInterval = setInterval(slideLoad, slideShow.displayTime[currentSlide]*1000);
} else {
// load the movie into the slideMov
slideMov.loadMovie(slideShow.fileName[currentSlide]);
trace("current slide display time= "+slideShow.displayTime[currentSlide]);
trace("current slide= "+currentSlide);
clearInterval(slideInterval);
++currentSlide;
// set the interval as to wich movies should be loaded when
slideInterval = setInterval(slideLoad, slideShow.displayTime[currentSlide]*1000);
}
};
//slideLoad();
// set the interval as to wich movies should be loaded when
slideInterval = setInterval(slideLoad, slideShow.displayTime[currentSlide]*1000);
};
mov_xml.ignoreWhite = true;
mov_xml.load("slideShow.xml");



the file "slideShow.xml" contains the following code:

<slideShow>
<slide url= "slideFilename.swf" time= "3"></slide>
<slide url= "slideFilename.swf" time= "1"></slide>
<slide url= "slideFilename.swf" time= "3"></slide>
<slide url= "slideFilename.swf" time= "4"></slide>
<slide url= "slideFilename.swf" time= "50"></slide>
<slide url= "slideFilename.swf" time= "50"></slide>
<slide url= "slideFilename.swf" time= "50"></slide>
<slide url= "slideFilename.swf" time= "50"></slide>
</slideShow>




so my question is simple.....


if you can understand this code and somehow know where i went wrong.. Please help because it would greatly be appriciated!


And for those of you who would like to help but can't be of any service maybe some suggestions would be considerd carefully....


If anyone knows alot about setInterval timer and how I could manipulate it so that it could work with varriable time please don't hessitate to reply to this post!!!


Of course this code is open source and may be used in your own personal projects... Please just give the appropriate credit to the people who deserve it where ever possible!!!



Please help....




Thank You

Grindstone Media

http://ww.grindstonemedia.co.za

simonboris
12-18-2003, 12:58 AM
try this

var jack=slideShow.displayTime[currentSlide]*1000;
slideInterval = setInterval(slideLoad, jack);