Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Community Boards > Just for Kicks Challenges

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-23-2005, 02:23 AM   #1
abacajan
Flash Game Enthusiast
 
abacajan's Avatar
 
Join Date: Jul 2005
Location: australia
Posts: 51
Send a message via MSN to abacajan
Post Countdown timer

Hey guys,
I thougtht i would try to make a timer to count down to christmas. Only to find out that this is incredibly hard. I eventually found out a way to do it but its a bit rough. It wont count down 12 months once i get past the 25th of december. But it will do the job fine from the 1st of january. What i would like to see is someone else try it. My script was fairly long and im sure there would be an easier way. What im looking for is a couple of dynamic textboxes for months, days, hours, minutes and seconds untill christmas. Lets say its the 5th of march
(my birthday). Instead of saying 9 months, 270 days (or whatever it might be) and so on, Im looking for 9 months, 26 days and so on. Good luck!

P.S ill post my swf and fla when i get enough response to this thread.

P.S.S
By the time people come accross this post itll probibly be past christmas and we will all be playing around with our new versions of flash 8! Yay!

See ya!
abacajan is offline   Reply With Quote
Old 12-23-2005, 02:43 AM   #2
Billy T
Oops I did it again
 
Billy T's Avatar
 
Join Date: Oct 2001
Location: Melbourne
Posts: 8,578
Default

do you want to use the users system clock or something more reliable like a PHP date object?
__________________
Billy
Online Galleries
Free Flash Video Tutorials
Photo Website Template

Don't email or PM me questions...
Billy T is offline   Reply With Quote
Old 12-28-2005, 01:54 AM   #3
Headshotz
TEAM INTERNET
 
Headshotz's Avatar
 
Join Date: Jul 2005
Location: Batcave
Posts: 2,759
Send a message via MSN to Headshotz
Default

Well it is past christmas, but make one for new years

I almost have it, this is just a test version
ActionScript Code:
//*********** //Another Code with pink //*********** //Yay, a timer, now I can dance createEmptyMovieClip("codeholder", 1); codeholder.onEnterFrame = function() {     today = new Date();     seconds = Math.floor((newyears.getTime()-today.getTime())/1000);     minutes = Math.floor(seconds/60);     hours = Math.floor(minutes/60);     days = Math.floor(hours/24);     cday = days;     if (cday<10) {         cday = "0"+cday;     }     chour = hours%24;     if (chour<10) {         chour = "0"+chour;     }     cminute = minutes%60;     if (cminute<10) {         cminute = "0"+cminute;     }     csecond = seconds%60;     if (csecond<10) {         csecond = "0"+csecond;     }     input = cday+" "+chour+" "+cminute+" "+csecond;     //Just this part is wrong     newyears = new Date(2005, 29, 12, 24); };

It doesnt quite work, by the way you have to draw the dynamic text box yourself and call it input
__________________
The author of windows file copy dialogue visits some friends:
"I'm just outside of town so I should be there in about 15 minutes"
"Actually it's looking more like 6 days"
"No, wait, 30 seconds"
Headshotz is offline   Reply With Quote
Old 01-03-2006, 07:04 PM   #4
invader
Dont set yourself on fire
 
invader's Avatar
 
Join Date: Aug 2005
Location: Arizona, USA
Posts: 238
Send a message via AIM to invader
Default

when posting code in forums, i usually try to make it 100% copy-and-paste-able. for the dynamic text field, you can just create it with createTextField, then add the text to it with .text=

that way, beginners can try out your script with little or no flash expertise required.

i like they script, btw.. i don't see too many people use modulo, and instead write a complex workaround for it.
invader is offline   Reply With Quote
Old 01-05-2006, 03:55 AM   #5
Headshotz
TEAM INTERNET
 
Headshotz's Avatar
 
Join Date: Jul 2005
Location: Batcave
Posts: 2,759
Send a message via MSN to Headshotz
Default

I found the code buried in one of my 1000's of unfinished flash files.
__________________
The author of windows file copy dialogue visits some friends:
"I'm just outside of town so I should be there in about 15 minutes"
"Actually it's looking more like 6 days"
"No, wait, 30 seconds"
Headshotz is offline   Reply With Quote
Old 01-06-2006, 09:06 PM   #6
abacajan
Flash Game Enthusiast
 
abacajan's Avatar
 
Join Date: Jul 2005
Location: australia
Posts: 51
Send a message via MSN to abacajan
Default wow

incredible how some people can do that just effortlessly with about 20 lines of code and mine took 7 hours and about 100 lines of code. sorry but i dont have my source code here with me right now. ill post it next saturday hopefully. (14/1/2006). By the way i used modulo in my script too to work out if it was a leap year like this:
ActionScript Code:
myDate=new Date(); year=myDate.getFullYear; if (year%4 !=0){     leapYear = false; } else if (year%4 = 0){     leapYear = true; }
By the way i suppose thats what defines an amature from a pro,
I know i could have just done this:
ActionScript Code:
myDate=new Date(); year=myDate.getFullYear; if (year%4 !=0){     leapYear = false; } else{     leapYear = true; }
but i find it easier to do it longer.
Ive also noticed pros do almost everything in variables for a game so its easier to change. but i have to go hunting!
abacajan is offline   Reply With Quote
Old 01-07-2006, 01:22 AM   #7
Headshotz
TEAM INTERNET
 
Headshotz's Avatar
 
Join Date: Jul 2005
Location: Batcave
Posts: 2,759
Send a message via MSN to Headshotz
Default



100 lines for a countdown timer, I dont know where this code came from, I dont remember writing it. Maybe I got it off a website and was modifying it.
__________________
The author of windows file copy dialogue visits some friends:
"I'm just outside of town so I should be there in about 15 minutes"
"Actually it's looking more like 6 days"
"No, wait, 30 seconds"
Headshotz is offline   Reply With Quote
Old 09-08-2006, 11:37 PM   #8
aaroncampbell
Registered User
 
Join Date: Oct 2005
Posts: 8
Default

I know this is more than a little late, but you do realize that technically we don't have a leap year every 4 years right? Technically it's:
All years divisible by 4, unless divisible by 100, unless divisible by 400.

So basically, 1996 IS because it's divisible by 4 and NOT 100. 1900 is NOT because although it is divisible by 4, it is ALSO divisble by 100. 2000 IS...it's divisible by 4 (so yes), but ALSO by 100 (so no), but then it IS divisble by 400 (so yes again). Check wikipedia http://en.wikipedia.org/wiki/Leap_ye...ve_a_leap_year

So, something more like this maybe:
Code:
if (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) {
    leapYear = true;
} else {
    leapYear = false;
}
aaroncampbell 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
How to modify this countdown timer code? ickwong ActionScript 2.0 4 11-13-2006 05:31 PM
Countdown Timer Problem RatoN ActionScript 2.0 8 11-27-2005 04:33 AM
please help! countdown timer problem dafnabru ActionScript 2.0 1 10-15-2005 03:36 PM
pause and resume timer countdown meisme ActionScript 1.0 (and below) 0 03-31-2005 02:06 AM
I have a question about a countdown timer thesilversliph ActionScript 1.0 (and below) 0 10-16-2002 03:02 PM


All times are GMT. The time now is 01:26 PM.


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