Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-16-2001, 02:46 AM   #1
udi
Registered User
 
Join Date: Aug 2001
Posts: 5
Send a message via ICQ to udi Send a message via AIM to udi Send a message via Yahoo to udi
Lightbulb

how do i do a count down timer in flash ??
udi is offline   Reply With Quote
Old 08-17-2001, 04:11 AM   #2
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

On a movie clip:
Code:
onClipEvent (load) {
	wait = 5;
	starTimer = true;
}
onClipEvent (enterFrame) {
	if (starTimer) {
		if (startTime == undefined) {
			startTime = getTimer()/1000;
		}
		curTime = getTimer()/1000;
		if ((curTime-startTime)>=wait) {
			starTimer = false;
			delete startTime;
			// actions to do after time is up
			trace ("bing!");
		} else {
			_root.timeRemaining = wait-(curTime-startTime);
		}
	}
}
To get it to start counting down, just set movieClipName.startTimer = true;
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 09-25-2001, 06:27 PM   #3
cinciem
Registered User
 
Join Date: Feb 2001
Location: cincinnati
Posts: 45
Question trying timer

Hi,

I am trying the timer too. I would like to countdown from 2 minutes in a dynamic text box. I tried this code, and it is giving me very strange results. I think that I am not understanding the variables that need to be created vs the code inante in Flash.

Could you comment this code and help me out? What is curTime? Could that be my dynamic text box variable?

I am trying to fight my way through this, but help would be wonderful.
cinciem is offline   Reply With Quote
Old 09-25-2001, 07:37 PM   #4
Strok
Registered User
 
Join Date: Nov 2000
Location: Toronto Canada
Posts: 798
Send a message via ICQ to Strok
Default

wait = 5; ---- time to count
curTime -- current time
timeRemaining -- dynamic text box


find more scripts here:

http://www.actionscripts.org/actions...&submit=SEARCH
Strok is offline   Reply With Quote
Old 09-26-2001, 01:40 PM   #5
cinciem
Registered User
 
Join Date: Feb 2001
Location: cincinnati
Posts: 45
Unhappy still trying

Thanks for your help. I checked out the resources you recomended- and I am getting there I think.

My goal is to count backwards from 2 minutes. In the past I have cheated with an animation of numbers that is based on fps. This is my first timer try (obviously).

This code gives my too many decimal places and counts forward. Could someone help me place the int correctly so it displays only 2 numbers.

Also, any suggestions on counting backwards?

onClipEvent (load) {
wait = 120;
starTimer = true;
}
onClipEvent (enterFrame) {
if (starTimer) {
if (startTime == undefined) {
startTime = getTimer()/1000;
}
curTime = getTimer()/1000;
if ((curTime-startTime)>=wait) {
starTimer = false;
delete startTime;
// actions to do after time is up
trace ("bing!");
} else {
_root.timer.timeRemaining = wait-int((curTime-startTime)/1000);
}
}
}

thanks for taking the time to help me out.
cinciem is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer stops on frame... sporkles ActionScript 2.0 2 01-17-2005 05:12 PM
Timer Troubles jwaller50 ActionScript 1.0 (and below) 4 01-05-2005 09:18 PM
Stop timer (); LocoDave ActionScript 1.0 (and below) 3 11-28-2004 10:10 PM
Timer (help needed) Queuer ActionScript 1.0 (and below) 4 12-07-2003 11:48 PM
interval timer The_Seademon ActionScript 1.0 (and below) 2 08-02-2003 09:23 PM


All times are GMT. The time now is 11:00 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.