Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

date to display

New Here ,
Jul 25, 2017 Jul 25, 2017

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.

297
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 25, 2017 Jul 25, 2017

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 i

...
Translate
Community Expert ,
Jul 25, 2017 Jul 25, 2017

var d:Date;

var dowA:Array=['Sunday','Monday',etc];

var moyA:Array=['January','February',etc];

var t:Timer=new Timer(1000,0;

t.addEventListener(TimerEvent.TIMER,f);

t.start();

function f(e:TimerEvent):void{

d=new Date();

tf.text = formatF(d);

}

function formatF(d:Date):String{

return dowA[d.day]+', '+moyA[d.month]+', '+d.fullYear;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 25, 2017 Jul 25, 2017
LATEST

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines