# Count down date?

**URL:** https://forum.kirupa.com/t/count-down-date/3666
**Category:** programming
**Created:** [November 11, 2001, 10:14pm UTC](https://forum.kirupa.com/t/count-down-date/3666 "2001-11-11T22:14:20Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 11, 2001, 10:14pm UTC](https://forum.kirupa.com/t/count-down-date/3666/1 "2001-11-11T22:14:20Z")

</div>

How would make a “mc” that acts as a count down date to a desired date, like christmas etc.?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 3:37am UTC](https://forum.kirupa.com/t/count-down-date/3666/2 "2001-11-12T03:37:51Z")

</div>

this took me much longer than i expected. tell me i’m missing something. isn’t there an easier way? btw, that function’s a handy way to tell if one number (num) is divisible by another (x).

make a dynamic text field called “daystil”, make it a movie put this in it:

```auto
  
onClipEvent(load){
//// functions
function divisibleby(num,x){
&nbsp &nbsp &nbsp &nbsp if(num/x - Math.floor(num/x) > 0){
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp return(0);
&nbsp &nbsp &nbsp &nbsp }else{
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp return(1);
&nbsp &nbsp &nbsp &nbsp }
}
////
&nbsp &nbsp &nbsp &nbsp // day in month array
&nbsp &nbsp &nbsp &nbsp dinm = [31,28,31,30,31,30,31,31,30,31,30,25];
&nbsp &nbsp &nbsp &nbsp now = new Date();

&nbsp &nbsp &nbsp &nbsp // if it's dec 26-31
&nbsp &nbsp &nbsp &nbsp if(now.getMonth()==11 && now.getDate()>25){
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // account for leap year
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if(divisibleby(now.getFullYear()+1,4)) dinm[1]=29;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // get days remaining in current month
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp daystil = 31 - now.getDate();
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // get days remaining for next year
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp for(j=0;j<12;j++){
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp daystil += dinm[j];
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }
&nbsp &nbsp &nbsp &nbsp }else{
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // account for leap year
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if(divisibleby(now.getFullYear(),4)) dinm[1]=29;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // get days remaining in current month
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp daystil = dinm[now.getMonth()] - now.getDate();
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // get days remaining for rest of the year
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp for(j=now.getMonth()+1;j<12;j++){
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp daystil += dinm[j];
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }
&nbsp &nbsp &nbsp &nbsp }
}

```

- edited to change i for j in the for loops \*

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 11:24am UTC](https://forum.kirupa.com/t/count-down-date/3666/3 "2001-11-12T11:24:09Z")

</div>

Hmmmm, didn’t seem to work , alls I get is the number 43.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 6:44pm UTC](https://forum.kirupa.com/t/count-down-date/3666/4 "2001-11-12T18:44:26Z")

</div>

and how many days are there to christmas?? ; )

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 6:56pm UTC](https://forum.kirupa.com/t/count-down-date/3666/5 "2001-11-12T18:56:32Z")

</div>

You tell him supra…lol thats the funniest ISH I have ever heard!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 6:58pm UTC](https://forum.kirupa.com/t/count-down-date/3666/6 "2001-11-12T18:58:46Z")

</div>

i had to smile. : )

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 7:21pm UTC](https://forum.kirupa.com/t/count-down-date/3666/7 "2001-11-12T19:21:41Z")

</div>

:lol: …no offence zao15…

it just made chuckle…

…b…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 8:40pm UTC](https://forum.kirupa.com/t/count-down-date/3666/8 "2001-11-12T20:40:36Z")

</div>

Hey supra…you got AIM…if so hit me up! You sound cool to talk to! If you don’t have that then give me your e-mail.

::AIM::  
\<a href=aim:GoIM?ScreenName=MeTHoDaN48&message=SUP\>MeTHoDaN48\</a\>

:📧:  
\<a [href=mailto:dan@danalu.com](mailto:href=mailto:dan@danalu.com)\>[dan@danalu.com](mailto:dan@danalu.com)\</a\>

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 11:41pm UTC](https://forum.kirupa.com/t/count-down-date/3666/9 "2001-11-12T23:41:57Z")

</div>

hah, wasn’t thinking =)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2001, 11:44pm UTC](https://forum.kirupa.com/t/count-down-date/3666/10 "2001-11-12T23:44:15Z")

</div>

I guess I should have been more specific. What I need is like a clock type countdown, but with dates, and mins, and sec…make sense?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 1:42am UTC](https://forum.kirupa.com/t/count-down-date/3666/11 "2001-11-13T01:42:01Z")

</div>

yes, there was a much easier way. i could have sworn i tried this but turns out i was just on glue. ; )

i got the core of this from [flash5actionscripts.com](http://flash5actionscript.com/dateobject2.php), which, incidentally, is a great site.

here’s the whole deal zao15, make a dynamic text box called “out”, make it a movie and put this in it:

```auto
onClipEvent(enterFrame){	xmas = new Date(2001, 11, 25);	now = new Date();	diff = xmas - now;	daystil = Math.floor(diff / 86400000);	hourstil = Math.floor((diff % 86400000) / 3600000);	minstil = Math.floor((diff % 3600000) / 60000);	secstil = Math.floor((diff % 60000) / 1000);	mstil = String(diff);	mstil = mstil.substr(-3);	out = daystil+" days, "+hourstil+" hours, "+minstil+" minutes, "+secstil+"."+mstil+" 'til xmas!";}

```

make “out” quite a wide text box.

cheers.

this board is f\*\*kin’ whacked sometimes. frustration after many edits to make this look normal.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 1:57am UTC](https://forum.kirupa.com/t/count-down-date/3666/12 "2001-11-13T01:57:38Z")

</div>

Thanks a lot man, I really do appreciate it. Where did you learn all your actionscript ability? Would you recommend any books for me? Thanks for that site too, thanks thanks thanks thanks =).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 2:24am UTC](https://forum.kirupa.com/t/count-down-date/3666/13 "2001-11-13T02:24:02Z")

</div>

i’ve never read an actionscript book in my life. mostly i learn from examples and just trying things.

i find the reference book that comes with flash (i usually read the version in the help files) is really quite good. it’s not really complete unfortunately, but what’s there is very helpful.

i’ve been very tempted to buy colin moock’s book though. as soon as i’m ready to part with the $40.

[www.macromedia.com/suppor…\_dict.html](http://www.macromedia.com/support/flash/action_scripts_dict.html) - this is the online version of the actionscript dictionary. it has a few more entries than the one on your hard drive.

[chattyfig.figleaf.com](http://chattyfig.figleaf.com) - there’s all kinds of stuff here. i just recently found this site. it’s deep.

[opaque.net/ming](http://opaque.net/ming) - a php extension for generating swfs. if you get to know this, you don’t even need flash! but it has to be installed on your server.

i’ll read any comments by musicman on the flashkit board. he’s really on the money.

boards like this are good.

incidentally, [www.confusion.tron-studios.com](http://www.confusion.tron-studios.com) comes up as server not found.

cheers.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 2:51am UTC](https://forum.kirupa.com/t/count-down-date/3666/14 "2001-11-13T02:51:10Z")

</div>

Yea i have to change that, as for right now, the website that I will be doing in flash is located at…[unf.getstung.com](http://unf.getstung.com)

thanks a lot for your help, i really appreciate them.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 6:57am UTC](https://forum.kirupa.com/t/count-down-date/3666/15 "2001-11-13T06:57:00Z")

</div>

\<embed src=“[http://www.danalu.com/xmastime.swf](http://www.danalu.com/xmastime.swf)” quality=high width=500 height=50\>

::IT WORKS::

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 9:46am UTC](https://forum.kirupa.com/t/count-down-date/3666/16 "2001-11-13T09:46:07Z")

</div>

zao15…

that is such a good idea… 🙂

countdown till site launch…

cheers…ben…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2001, 12:36pm UTC](https://forum.kirupa.com/t/count-down-date/3666/17 "2001-11-13T12:36:51Z")

</div>

🙂 , thanks, but really all the credit goes to suprabeener.
