PDA

View Full Version : Count down date?



zao15
November 11th, 2001, 05:14 PM
How would make a "mc" that acts as a count down date to a desired date, like christmas etc.?

suprabeener
November 11th, 2001, 10:37 PM
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:

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

zao15
November 12th, 2001, 06:24 AM
Hmmmm, didn't seem to work , alls I get is the number 43.

suprabeener
November 12th, 2001, 01:44 PM
and how many days are there to christmas?? ; )

dan4885
November 12th, 2001, 01:56 PM
You tell him supra...lol thats the funniest ISH I have ever heard!

suprabeener
November 12th, 2001, 01:58 PM
i had to smile. : )

gingerhippy69
November 12th, 2001, 02:21 PM
:lol: ...no offence zao15...

it just made chuckle...

...b...

dan4885
November 12th, 2001, 03:40 PM
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>

::e-mail::
<a href=mailto:dan@danalu.com>dan@danalu.com</a>

zao15
November 12th, 2001, 06:41 PM
hah, wasn't thinking =)

zao15
November 12th, 2001, 06:44 PM
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?

suprabeener
November 12th, 2001, 08:42 PM
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:


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.

zao15
November 12th, 2001, 08:57 PM
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 =).

suprabeener
November 12th, 2001, 09:24 PM
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 comes up as server not found.

cheers.

zao15
November 12th, 2001, 09:51 PM
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.

dan4885
November 13th, 2001, 01:57 AM
<embed src="http://www.danalu.com/xmastime.swf" quality=high width=500 height=50>

::IT WORKS::

gingerhippy69
November 13th, 2001, 04:46 AM
zao15...

that is such a good idea... :)

countdown till site launch....

cheers..ben...

zao15
November 13th, 2001, 07:36 AM
:) , thanks, but really all the credit goes to suprabeener.