Halapino
01-08-2011, 10:14 PM
The clock displays, but the numbers overwrite themselves to create a blur. I cannot figure out how to get the text to refresh. On a side note, I cannot get the hours/minutes/seconds to get a zero added if they are under 10, keep getting told I can't combine a string with a number.
dateText.addEventListener(Event.ENTER_FRAME,showDa te);
private function showDate(event:Event):void{
var dText:TextField = new TextField();
var theDay:String = new String();
var theMonth:String = new String();
var theDate:Number = new Number();
var theYear:Number = new Number();
var theMinutes:Number = new Number();
var theHours:Number = new Number();
var theSeconds:Number = new Number();
var myDate:Date = new Date();
var ampm:String = new String();
//Retrieve the day, month and year from the date class.
var weekdays:Array = new Array ("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
var months:Array = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug", "Sep", "Oct","Nov","Dec");
theDay=weekdays[myDate.getDay()];
theMonth=months[myDate.getMonth()];
theDate=myDate.getDate();
theYear=myDate.getFullYear();
theHours=myDate.getHours();
theMinutes=myDate.getMinutes();
theSeconds=myDate.getSeconds();
//put zeros where needed
//if (theHours<10) { theHours = "0" + theHours; } else { theHours = theHours; }
//if (theMinutes<10) {theMinutes = "0" + theMinutes;} else {theMinutes = theMinutes;}
//if (theSeconds<10) {theSeconds = "0" + theSeconds;} else {theSeconds = theSeconds;}
if (theHours>12 ) {theHours = theHours-12; ampm = "PM";} else
if (theHours == 12) {ampm = "PM";} else {ampm = "AM";}
if (theHours == 0) {theHours = 12;}
//Display the date in the dynamic text field.
dText.width = 350;
dText.height = 40;
dText.x = (stage.stageWidth)/2 - (dText.width)/2;
dText.y = 10;
dText.scaleY=2
// does not work! dText.text="";
dText.text=theDay+", "+theMonth+" "+theDate+", "+theYear+" - "+theHours+":"+theMinutes+":"+theSeconds+" "+ampm;
addChild(dText);
}
dateText.addEventListener(Event.ENTER_FRAME,showDa te);
private function showDate(event:Event):void{
var dText:TextField = new TextField();
var theDay:String = new String();
var theMonth:String = new String();
var theDate:Number = new Number();
var theYear:Number = new Number();
var theMinutes:Number = new Number();
var theHours:Number = new Number();
var theSeconds:Number = new Number();
var myDate:Date = new Date();
var ampm:String = new String();
//Retrieve the day, month and year from the date class.
var weekdays:Array = new Array ("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
var months:Array = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug", "Sep", "Oct","Nov","Dec");
theDay=weekdays[myDate.getDay()];
theMonth=months[myDate.getMonth()];
theDate=myDate.getDate();
theYear=myDate.getFullYear();
theHours=myDate.getHours();
theMinutes=myDate.getMinutes();
theSeconds=myDate.getSeconds();
//put zeros where needed
//if (theHours<10) { theHours = "0" + theHours; } else { theHours = theHours; }
//if (theMinutes<10) {theMinutes = "0" + theMinutes;} else {theMinutes = theMinutes;}
//if (theSeconds<10) {theSeconds = "0" + theSeconds;} else {theSeconds = theSeconds;}
if (theHours>12 ) {theHours = theHours-12; ampm = "PM";} else
if (theHours == 12) {ampm = "PM";} else {ampm = "AM";}
if (theHours == 0) {theHours = 12;}
//Display the date in the dynamic text field.
dText.width = 350;
dText.height = 40;
dText.x = (stage.stageWidth)/2 - (dText.width)/2;
dText.y = 10;
dText.scaleY=2
// does not work! dText.text="";
dText.text=theDay+", "+theMonth+" "+theDate+", "+theYear+" - "+theHours+":"+theMinutes+":"+theSeconds+" "+ampm;
addChild(dText);
}