As a minor element of a project, I have the following code to call the current date and time to be displayed in the format: 'Tue 12:26 PM' within a dynamic text box.
ActionScript Code: var dtDay:Array = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var dtHours:Array = ["12","1","2","3","4","5","6","7","8","9","10","11","12","1","2","3","4","5","6","7","8","9","10","11"];var dtMins:String;var ampm:String;var dateTimer:Timer = new Timer(1000);dateTimer.addEventListener(TimerEvent.TIMER, updateTime);dateTimer.start();function updateTime(event:TimerEvent):void{ var datetime:Date = new Date(); if (datetime.hours >= 12) { ampm = " PM"; } else { ampm = " AM"; } if (datetime.minutes <= 9) { time_txt.text = String((dtDay[datetime.day]) + " " + (dtHours[datetime.hours]) + ":0" + datetime.minutes + ampm); } else { time_txt.text = String((dtDay[datetime.day]) + " " + (dtHours[datetime.hours]) + ":" + datetime.minutes + ampm); }}
The code displays the following when run 'Tue PM', and I am unsure as to the source of the problem. It appeared to be working fine yesterday at different points in the day (3:10, 4:45, 5:00pm, etc.)
Help would be greatly appreciated. Still rather new to this.
Any reason why this time generator isn't working properly?
Wednesday, May 16, 2012
[Action Script] Any reason why this time generator isn't working properly? May,2012
Posted by Bimo Hery Prabowo at 7:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment