getTimer doesn't re-initialize?

I have a simple slideshow that is non-interactive. It just loops five movie clips loaded externally. Each slide is shown for a certain amount of time that is determined with getTimer.

The code for the slideshow is in the last frame of the root timeline. So, basically the slideshow starts when the root timeline finishes playing. The problem is that the timer works great the first time the code plays, but when I tell the player head to back up and enter the frame again, the clips play very rapidly, as though getTimer was not being initialized.

Here is the code:

stop();
square._alpha = 0;
mypic = 1;
_root.onEnterFrame = function() {
if (square._alpha<10) {
loadMovie(“images/image”+mypic+".swf", “square”);
fadeOut = false;
fadeIn = true;
}
if (square._alpha>10 && fadeOut) {
square._alpha -= 10;
}
if (square._alpha<100 && fadeIn && !fadeOut) {
square._alpha += 10;
} else {
fadeIn = false;
}
if (mypic>=10) {
mypic = 1;
startTimeSet = 0;
}
if (getTimer()>10000 && mypic<10 && !fadeIn && !fadeout && mypic == 1) {
fadeout = true;
mypic = 2;
}
if (getTimer()>15000 && mypic<10 && !fadeIn && !fadeout && mypic == 2) {
fadeout = true;
mypic = 3;
}
if (getTimer()>20000 && mypic<10 && !fadeIn && !fadeout && mypic == 3) {
fadeout = true;
mypic = 4;
}
if (getTimer()>25000 && mypic<10 && !fadeIn && !fadeout && mypic == 4) {
fadeout = true;
mypic = 5;
}
if (getTimer()>30000 && mypic<10 && !fadeIn && !fadeout && mypic == 5) {
fadeout = true;
startTimeSet = 0; //not sure if this is necessary - i think i’m telling getTimer
//to reset itself at this point?
gotoAndPlay(“rewind”); // telling the player head to back up a couple of
// frames and then play forward again to loop the images again
}
};

[AS]
stop();
function slideShow() {
square._alpha = 0;
mypic = 1;
myTime = getTimer();
_root.onEnterFrame = function() {
if (square._alpha<10) {
loadMovie(“images/image”+mypic+".swf", “square”);
fadeOut = false;
fadeIn = true;
}
if (square._alpha>10 && fadeOut) {
square._alpha -= 10;
}
if (square._alpha<100 && fadeIn && !fadeOut) {
square._alpha += 10;
} else {
fadeIn = false;
}
if (mypic>=10) {
mypic = 1;
startTimeSet = 0;
}
if (myTime-getTimer()>10000 && mypic<10 && !fadeIn && !fadeout && mypic == 1) {
fadeout = true;
mypic = 2;
}
if (myTime-getTimer()>15000 && mypic<10 && !fadeIn && !fadeout && mypic == 2) {
fadeout = true;
mypic = 3;
}
if (myTime-getTimer()>20000 && mypic<10 && !fadeIn && !fadeout && mypic == 3) {
fadeout = true;
mypic = 4;
}
if (myTime-getTimer()>25000 && mypic<10 && !fadeIn && !fadeout && mypic == 4) {
fadeout = true;
mypic = 5;
}
if (myTime-getTimer()>30000 && mypic<10 && !fadeIn && !fadeout && mypic == 5) {
fadeout = true;
startTimeSet = 0;

gotoAndPlay(“rewind”);
// _root.onEnterFrame = null;
}
};
}
slideShow();[/AS]
as you can see I putted everything inside a function
I use the new variable myTime to check the getTimer value when the function is called. the getTimer function is actually imposible to reset but it can be used in this case anyway.

Hi Dulcinea,

Thanks for your quick reply. That is a good idea, but in practice the slideshow never advances to the second frame, because since myTime and getTimer start out equal to each other MyTime-GetTimer will never go above 1. (it needs to go above 10000 to get to the second frame) Am I right? I have tested the code and it seems to stall on the first picture, anyway.