PDA

View Full Version : Slideshow 2 (was "SKIDESHOW")


yowl
09-07-2002, 12:05 AM
I am trying to show a series of images with a delay between images.

I tried inserting different several bits of code (from the Actionscript.org library) with various timer strategies.
I get no syntax error, but when I run it, either with test movie, or publishing it and viewing it in the browser, it stands still for a while, then shows the last image.

I have Flash MX bible, but don't know what question to ask...what to look up.

//////////////////////////////////////////////////////// the code;

imgs =["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"]
_root.holder.onEnterFrame = function() {
for(i=0; i<imgs.length; i++){
holder.loadMovie("c:/rwtemp/"+imgs[i]);
now = getTimer();
start = getTimer();
while (start+1000>now) {
now = getTimer();
} // end While loop

} // end FOR loop
} // end function

/////////////////////////////////////////

Any hints would be greatly appreciated.

I have one layer with the script in frame one, and one layer with the movieclip "holder in frame one. The clip does display at the end, but as I said, only the last image, after a long delay with no activity.

Jesse
09-07-2002, 09:56 AM
You can't use a while loop to pause. See the Delaying Events tutorial. Read that for info on how and why you can't. Then use setInterval if you have Flash MX.

yowl
09-07-2002, 09:43 PM
Thank you for your reply,
I tried this one before, attempting to do one iteration of the FOR loop, then use setInterval to wait 4.5 seconds, and call an empty function, come back, do next iteration....etc.

I still get a pause, then display of the last image in the array of image names.

//////////////////////////////////////////////////////////////
imgs =["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"]
_root.holder.onEnterFrame = function() {
for(i=0; i<imgs.length; i++){
holder.loadMovie("c:/rwtemp/"+imgs[i]);
setInterval(nada, 4500);
}// end FOR loop
}// end FUNCTION


function nada(){
//do nothing
}// end FUNCTION

/////////////////////////////////////////////////

Jesse
09-08-2002, 12:33 AM
Did you read the tute? The tute explains taht you can't use for loops either.

If you plan to use setInterval you have to put all the actions you want to occur once the interval is up in a function. Then create a setInterval and set the time to however long you want to wait before running the functions. Your function should delete the interval once it is run.

Note I'm usure as to whether setInterval runs the function immediately, then waits X seconds, or if the first run of the function is after X seconds. I think it runs it first, in which case you don't want to do the actions first time around. Keep a counter or some such.