PDA

View Full Version : Reset getTimer function?



alacid71
June 4th, 2002, 06:31 AM
hi there!, here's the deal...

I have an empty movie clip that tells another movie clip on the stage to move based on a variable that's based on the getTimer results something like:

onClipEvent (enterFrame) {
&nbsp &nbsp &nbsp &nbsp targetx = 0;
_root.slide.gotoAndPlay("move");

start = getTimer();
if (start>4000) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp targetx = -468;
_root.slide1.gotoAndPlay("move");
}

Now, what I want to do is to reset the value of getTimer so my movie will loop, does anybody know how to do that?, or maybe an easier solution?

Tanks to anybody with help

ilyaslamasse
June 4th, 2002, 06:56 AM
onClipEvent (load) {

start = getTimer () ;

}

onClipEvent (enterFrame) {

now = getTimer () - start ;

if (now>4000) {

start = getTimer () ;

//do stuff

}

}Does this help ?

pom 0]

alacid71
June 4th, 2002, 07:41 AM
WOW!! that was quick... I'll give it a shot see if it works...

thanks so much, although I've been with AS for a year, I still feel like a newbie

paco

alacid71
June 5th, 2002, 02:11 AM
I tried with the solution you posted, but I can't ,make it work... if

onClipEvent (load) {
start = getTimer () ;
}
onClipEvent (enterFrame) {
now = getTimer () - start ;
if (now>4000) {
start = getTimer () ;
//do stuff
}
}

am I really re-setting the timer?, I mean, what I do with this is give a value of 0 to the variable "now", maybe I donīt get it... plus, how do I make the loop so getTimer will start counting again?

thanks

Paco

ilyaslamasse
June 5th, 2002, 10:50 AM
Well, if you do
onClipEvent (load) {

start = getTimer () ;

}

onClipEvent (enterFrame) {

now = getTimer () - start ;

if (now>4000) {

start = getTimer () ;

trace (i++) ;

}

}you reset the timer in the way that it will increment and display i every 4 seconds.

You see, to reset the timer, you have to have some kind of reference point : it's the start variable. When the clip loads, this is the origin. Then on each frame, you check the time. But the elapsed time is the difference between the present time and the origin of times. And when a condition is fulfilled (here : time>4000) then the origin becomes the current time.

Still unclear ?

pom 0]

alacid71
June 5th, 2002, 02:48 PM
AHHHH!... now I got it, thanks so much for the clarification, that was really helpful

paco