Using someone’s code but I can not figure out why the time keeps vanishing from the screen.
import flash.utils.Timer;
import flash.events.TimerEvent;
var time:Timer = new Timer(1000);
var date:Date = new Date();
var day:Number = date.day;
var hour:* = date.hours;
var minutes:* = date.minutes;
var seconds:* = date.seconds;
hideDaysAMPM(sun, mon, tue, wed, thu, fri, sat, am, pm);
function hideDaysAMPM(...hideDAP)
{
for (var i:int = 0; i<hideDAP.length; i++)
{
hideDAP*.visible = false;
}
}
switch (day)
{
case 0 :
sun.visible = true;
break;
case 1 :
mon.visible = true;
break;
case 2 :
tue.visible = true;
break;
case 3 :
wed.visible = true;
break;
case 4 :
thu.visible = true;
break;
case 5 :
fri.visible = true;
break;
case 6 :
sat.visible = true;
break;
}
time.addEventListener(TimerEvent.TIMER, startTime);
time.start();
function startTime(e:TimerEvent):void{
date = new Date();
hour = date.hours;
minutes = date.minutes;
seconds = date.seconds;
if (Number(hour) > 12){
hour -= 12;
pm.visible = true;
}
else{
am.visible = true;
}
if(String(hour).length < 2) {
hour = "0" + hour;
}
if(String(minutes).length < 2) {
minutes = "0" + minutes;
}
if(String(seconds).length < 2) {
seconds = "0" + seconds;
}
clockTxt.text = hour + ":" + minutes + ":" + seconds;
}