date to display
I want to create a swf file which displays date in the format Tuesday, July 25, 2017 and updates it with current time
please suggest me a solution.
I want to create a swf file which displays date in the format Tuesday, July 25, 2017 and updates it with current time
please suggest me a solution.
AS3 supports a more direct method for doing this sort of thing.
function updateDate(evt:TimerEvent):void {
var d:Date = new Date();
var df:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT);
df.setDateTimePattern("EEEE, MMMM d, yyyy");
var fd:String = df.format(d);
trace(fd);
}
DateTimeFormatter - Adobe ActionScript® 3 (AS3 ) API Reference
As for automatic updating, while you could schedule a timer to fire every 24 hours, the probability of timer drift is high. The function itself is so trivial that there would be no harm in calling it once a minute (every 60,000 milliseconds). So something like...
var myTimer:Timer = new Timer(60000);
myTimer.addEventListener(TimerEvent.TIMER, updateDate);
myTimer.start();
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.