# Count down date?

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

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:

``````
//// 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 *

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

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

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

i had to smile. : )

:lol: …no offence zao15…

…b…

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>

hah, wasn’t thinking =)

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?

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, 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:

``````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.

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 =).

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 - 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 - there’s all kinds of stuff here. i just recently found this site. it’s deep.

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.

cheers.

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

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

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

::IT WORKS::

zao15…

that is such a good idea…

countdown till site launch…

cheers…ben…

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