For the series "How I Did It" (or as I did) here is how to make a countdown to see in Flash, starting with a date, what days, hours, minutes and seconds are missing an event! The Flash movie below, for example, see how many days the first year! They can be used pull-down menus to select a different date:
We create three combo day_cmb, month_cmb year_cmb and initialize them:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | / / Init combo controls . ComboBox ; import mx. controls. ComboBox; / / var i = 1 ; i < 32 ; i ++ ) { for (var i = 1, i <32; i + +) { i , i ) ; day_cmb. addItem (i, i); } var i = 0 ; i < 12 ; i ++ ) { for (var i = 0; i <12; i + +) { sm [ i ] , i ) ; month_cmb. addItem (sm [i], i); } / / I as from today ... var i = 2007 ; i < 2020 ; i ++ ) { for (var i = 2007; i <2020; i + +) { i , i ) ; year_cmb. addItem (i, i); } / / Set the date to January 1, 2008 ; // -1 day_cmb. selectedIndex = 0; / / -1 ; // -1 month_cmb. selectedIndex = 0; / / -1 ; year_cmb. selectedIndex = 1; |
The heart of the system we place the onEnterFrame event:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | onEnterFrame = function ( ) { this. onEnterFrame = function () { / / Date = new Date ( ) ; var today: Date = new Date (); getFullYear ( ) ; var today = currentYear. getFullYear (); getTime ( ) ; var today = currentTime. getTime (); / / getTime ( ) ; var = targetTime targetDate. getTime (); / / currentTime ; var = targetTime TimeLeft - currentTime; / / . floor ( timeLeft / 1000 ) ; var c = Math . floor (TimeLeft / 1000); = Math . floor ( sec / 60 ) ; var min = Math . floor (sec / 60); . floor ( min / 60 ) ; var hrs = Math . floor (min / 60); . floor ( hrs / 24 ) ; var days = Math . floor (hrs / 24); / / sec % 60 ) ; sec = String (sec% 60); length < 2 ) ? "0" + sec : sec ; sec = (sec. length <2)? "0" + sec: sec; / / ( min % 60 ) ; min = String (min% 60); min . length < 2 ) ? "0" + min : min ; = min (min. length <2)? "0" + min: min; / / hrs % 24 ) ; hrs = String (hrs% 24); length < 2 ) ? "0" + hrs : hrs ; mins = (hrs. length <2)? "0" + hrs: mins; / / days ) ; days = String (days); length < 2 ) ? "0" + days : days ; = days (days. length <2)? "0" + days: days; / / String = days + ":" + hrs + ":" + min + ":" + sec ; var counter: String = days + "" + hrs + ":" + min + ":" + sec; / / = counter ; time_txt. text = counter; }; |










I was looking if there are bugs in the management Date () in Flash and Google brought me here. I was trying a Countdown like this and I noticed that a wrong time. But only if there is a change of half a month, you can try it on. Increasing by one month (from the present to the next) is not only increased the days (30 or 31 that is) but it also increases the time on a unit or Baco ... bug?
Obviously I have not calculated the time zone ... my mistake ...
[...] Post by 3D CountDown FIVe3D (see also How I Did It: write a countdown in Flash), was given a class for creating an object in Actionscript CountDown, here's one [...]
Hello, How do I enter the function NOW PROVIDES event?
Let me explain:
In this countdown you can 'just put a date DD / MM / HH how do I get the exact time of that day?
Example:
January 12, 2009 15.00
Thanks
@ Fabrizio: line 7 in the second listing, use the
new Date()to create the arrival of the countdown. You see, in this example, the constructor function is passed the year, month and day. However, the constructor functionnew Date(), how can you verify dall'Help Flash, accepts additional parameters (optional) such as hours, minutes, seconds and milliseconds.@ Giovambattista Fazioli:
Ok I solved this, I managed to get the exact time, now I would put a message at the end of the countdown instead to continue the countdown, I do not know if I was clear.
type at the end of the countdown I'd like to write OFFER EXPIRED.
Thanks always
@ Fabrizio: this is quite simple. Line 10 is valued variable
timeLeft, which represents the difference between the current and target. When this variable is equal to zero (or is less than zero) means that the "time" has expired.@ Giovambattista Fazioli:
you please give an example of how the line should be 10 if I wanted to add at the end of the countdown OFFER EXPIRED.
Thanks
PS I'm sorry but I am now starting to use flash ..
@ Giovambattista Fazioli:
I just can not shame on me.
listen and if I wanted to stop the countdown at the end of the countdown, I have to do?
My current when it reaches the end of time continues to write numbers with a minus sign should I do??
Thanks always