Skip to main content
Brimstone0323
Participant
September 26, 2016
Question

Basic Date/Time Display

  • September 26, 2016
  • 1 reply
  • 1093 views

Hello All,

I am new to Flash/Animate and I have built a Date/Time module for our digital signage system at work. It works well when I preview it and I am able to open it in several different browsers locally, but when I push it to the player, it blinks. Can anyone guide me in the right direction as to what I have done wrong? We have an .SWF file that was given to us by the manufacturer of the system that works great, but we needed to change a few details. Unfortunately, I do not have access to the .FLA used to create the working file, so I built this one from scratch. The players use Internet Explorer to display Flash animations. Please let me know if there is any more info you need from me.

Thanks,

-John

*****

import flash.utils.Timer;

var myTimer:Timer = new Timer (100);

myTimer.addEventListener(TimerEvent.TIMER, go);

myTimer.start();

updateTime();

function go(event:TimerEvent):void

{

  updateTime();

}

function updateTime():void

{

  var date = new Date();

  var minutes:uint = date.getMinutes();

  var hours:uint = date.getHours();

  var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

  var day_str:String = dayOfWeek_array[date.getDay()];

  var monthOfYear_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

  var month_str:String = monthOfYear_array[date.getMonth()];

  var dateX:uint = date.getDate();

  var yearX:uint = date.getFullYear();

  var ampm

  if (hours > 12)

  {

  hours = hours - 12

  ampm = "PM"

  }

  else

  {

  ampm = "AM"

  }

  digitalClock.text = hours + ":" + pad(minutes) + " " + ampm;

  dateMod.text = day_str + ", " + month_str + " " + dateX + ", " + yearX;

}

function pad (number:Number)

{

  var new_num:String = String (number);

  if (new_num.length <2)

  {

  new_num = "0" + new_num

  }

  return new_num

}

*****

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
September 26, 2016

i'm not sure what you mean by ".. it blinks" but you can check to see if the text property needs to be updated before changing it:

import flash.utils.Timer;

var myTimer:Timer = new Timer (100);

myTimer.addEventListener(TimerEvent.TIMER, go);

myTimer.start();

updateTime();

function go(event:TimerEvent):void

{

updateTime();

}

function updateTime():void

{

var date = new Date();

var minutes:uint = date.getMinutes();

var hours:uint = date.getHours();

var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

var day_str:String = dayOfWeek_array[date.getDay()];

var monthOfYear_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var month_str:String = monthOfYear_array[date.getMonth()];

var dateX:uint = date.getDate();

var yearX:uint = date.getFullYear();

var ampm

if (hours > 12)

{

hours = hours - 12

ampm = "PM"

}

else

{

ampm = "AM"

}

if(digitalClock.text!=hours + ":" + pad(minutes) + " " + ampm){

digitalClock.text = hours + ":" + pad(minutes) + " " + ampm;

}

if(dateMod.text!=day_str + ", " + month_str + " " + dateX + ", " + yearX){

dateMod.text = day_str + ", " + month_str + " " + dateX + ", " + yearX;

}

}

function pad (number:Number)

{

var new_num:String = String (number);

if (new_num.length <2)

{

new_num = "0" + new_num

}

return new_num

}

*****

Brimstone0323
Participant
September 26, 2016

By blinking I mean, it alternates between showing the module and a black box where the module should be. I will test your suggestion and see where that gets me. Thank you very much for taking the time to help.

kglad
Community Expert
Community Expert
September 26, 2016

i don't know what "..the module" is.

do you have a link that shows your display and illustrates the issue?