Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


how to do a timer



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Flash Forum
View previous topic :: View next topic  
Author Message
legalnine



Joined: 04 Jan 2007
Posts: 5

PostPosted: Mon Jan 08, 2007 1:40 pm    Post subject: how to do a timer Reply with quote

hi there!! is there such a thing as countdown timer in flash 8? like from 30 secs all the way to 0.

if there is.. could anyone pleaseee teach mi how to do one?

thanks thanks
Back to top
View user's profile Send private message
gszauer



Joined: 11 Jan 2007
Posts: 3

PostPosted: Thu Jan 11, 2007 10:23 pm    Post subject: Re: how to do a timer Reply with quote

There is a built in function, but i wrote one that i use, it makes more sence to me.
This will output time in mm:ss format (m-minutes, s-seconds).
There are 2 variables you need to change, they are commented on in the script.
After calling the script in an enter frame, the remaining time becomes avalible as _root.currentTime
Just copy/paste this script into a blank frame on the root timeline to see it in action.

Code:
//////////////////////////////////////////
//    Code Provided By Gabor Szauer    //
//          http://szauer.net          //
/////////////////////////////////////////
time = 150; // The time you want to count down (In seconds)
fps = 12; // The FPS of your movie (12 by default)
time_left = time*fps;
function countdown() {
   time_left--;
   minutesLeft = Math.floor(((time_left/12)/60));
   secondsLeft = Math.floor(((time_left/12)%60));
   if (secondsLeft<10) {
      secondsLeft = "0"+secondsLeft;
   }
   if (minutesLeft<10) {
      minutesLeft = "0"+minutesLeft;
   }
   _root.currentTime = minutesLeft+":"+secondsLeft;
   trace(currentTime);
}
_root.onEnterFrame = function() {
   countdown();
};
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Flash Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap