...

View Full Version : A Flash timing question!!



jcdevelopment
01-18-2008, 02:51 PM
How can i get a timer to when after 10 seconds or more it will move to the next frame. I know there are ways to do this i have seen it before. If anyone has suggestion or a web site that would help.

Thank you for any suggestions!

_Aerospace_Eng_
01-18-2008, 03:22 PM
You will want to create a function that calls gotoAndStop(framenumber). You then want to call this function using setInterval(this,"functionname()",10000);

I've found that anything smaller than 1 second creates an overhead and causes high cpu usage.

jcdevelopment
01-18-2008, 03:36 PM
Ok i get what your saying the only problem is that i am kinda new to Flash, so do i write a function like i would write a JS function?

ok i got it, i believe i figured it out, thank you for your help; this is what i used:




Time = setInterval(switchFrame,10000);

function switchFrame():Void {
if(_currentframe<_totalframes) {
gotoAndStop(6);
} else {
gotoAndStop(1);
}
clearInterval(Time);
}

stop();

_Aerospace_Eng_
01-18-2008, 10:31 PM
You don't really want to clear the interval because then it won't keep rotating. To keep it continously rotating just don't clear the interval. Look into the setInterval syntax again. What I posted is what I used and it works. Don't know if yours will work or not. Yes you are correct on how to write the function. You don't really need the void part there.

jcdevelopment
01-18-2008, 10:50 PM
it, works, but you are right i dont need to clear the interval, thankyou!!

_Aerospace_Eng_
01-19-2008, 02:30 AM
I was assuming you were just calling all of your actionscript from one frame. I see that this may not be the case in which point I would use setTimeout instead because setInterval will keep being called and it might cause overhead. So with that said try this instead

Time = setTimeout(switchFrame,10000);

function switchFrame():Void {
if(_currentframe<_totalframes) {
gotoAndStop(6);
} else {
gotoAndStop(1);
}
}

stop();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum