all groups > flash (macromedia) > january 2005 >
You're in the

flash (macromedia)

group:

getTimer() - can it be re-set?



getTimer() - can it be re-set? Steve Harris
1/18/2005 11:29:30 PM
flash (macromedia): I'm trying to make an automated slide show which changes the slides after a
pre-determined period of time. This is in a SWF which I load into another
SWF file.I am OK to begin with because I set the initial time to getTimer()
and just load the images at pre-determined intervals after that. My problem
is that when I re-load the slide show it can't go back to the beginning
because the timer is based on getTimer(), which is measuring time since the
host SWF started running.
So my question is, is it possible to code it so getTimer() goes back to the
beginning?


Re: getTimer() - can it be re-set? Dan_Linfield NO[at]SPAM discovery.com
1/19/2005 12:09:41 PM
Hi Steve,

getTimer() is a global property and can't be reset. Flash has internal
timer that starts running as soon as your swf is loaded and runs as
long as long as the swf is active.

The common use of getTimer is to sort of take a snapshot of getTimer's
current value

stoppedTime = getTimer()

Then use a repeating movie clip to start checking the current getTimer
and compare it to your snapshot.

if (getTimer() - stoppedTime > 10000) {
// 10 seconds is up, load my next swf
}


A slicker way to do it use setInterval

first, make a function that loads the next swf

function myLoader() {
++count
target.loadMovie("mySwf" + count)
if (count > 15) {
clearInterval(loadInterval) // this shuts off the interval after 15
swfs have loaded
}
}

then use setInterval to trigger the function at a certain interval

loadInterval = setInterval(myLoader, 10000)


[quoted text, click to view]
AddThis Social Bookmark Button