I have just got my self into coding however I'm still learning and after searching everywhere last week I have given up.
I have a an old AS2 sript that I have compiled from various sources and created a count up clock for a friend website. Now the issue I have is that we all know flash will not be supported for much longer and is currently being phased out. Since this is the case can someone please convert the following code to AS3 or perhaps into JavaScript.
I have tried looking at countdown timers in AS3 but for the life of me I can't figure this out.
I hope someone can help of point me in the right direction.
Thank you for your help in advance.
// set date variables
var year = 1961;
var month = 3; // (number -1 as zero indexed array)
var day = 28;
var hour = 16; // (24 hour)
var minute = 40;
var second = 0;
start = new Date(year, month, day, hour, minute, second);
function calcAge() {
var now = new Date();
var o = new Object();
o.calendar_years = now.getYear()-start.getYear();
o.calendar_months = now.getMonth()-start.getMonth();
o.calendar_days = now.getDate()-start.getDate();
o.calendar_hours = now.getHours()-start.getHours();
o.calendar_minutes = now.getMinutes()-start.getMinutes();
o.calendar_second = now.getSeconds()-start.getSeconds();
if (o.calendar_second<0) {
o.calendar_second += 60;
o.calendar_second--;
}
if (o.calendar_minutes<0) {
o.calendar_minutes += 60;
o.calendar_hours--;
}
if (o.calendar_hours<0) {
o.calendar_hours += 24;
o.calendar_days--;
}
if (o.calendar_days<0) {
// Days need to be taken from first day of the month
var nextmonth = new Date(now.getYear(), now.getMonth(), 32);
o.calendar_days += 32-nextmonth.getDate();
o.calendar_months--;
}
if (o.calendar_months<0) {
o.calendar_months += 12;
o.calendar_years--;
}
return o;
}
function getAge(){
age = calcAge();
years_txt.text = age.calendar_years;
months_txt.text = age.calendar_months;
day_txt.text = age.calendar_days;
hour_txt.text = age.calendar_hours;
mins_txt.text = age.calendar_minutes;
sec_txt.text = age.calendar_second;
}
var intervalID = setInterval( getAge, 1000 );