Date and Time action script

Asked By 10 points N/A Posted on -
qa-featured

I am making a screen saver for a cell phone using Macromedia Flash 8 and I want it to have the current date and time features. I am using a Text tool with a property of Input Text as for the display of date and time. I am having a trouble using the script; I created an array for the name of the months but unable to get the value for date and time. Kindly assist me with this one.

SHARE
Answered By 0 points N/A #126118

Date and Time action script

qa-featured

Using a script assist on actions is much easier, at first Action Script was designed to control animations with 2D vector later on it has an additional functions that can be use to create a Web-based applications and games. If you want to use Action Script on your screen saver then you can follow these codes that I will give you:

  • First you must get the current date and time

dateNow = new Date();

  • I supposed this is similar to your month array

var month = new Array();

month[0] = "January";

month[1] = "February";

month[2] = "March";

month[3] = "April";

month[4] = "May";

month[5] = "June";

month[6] = "July";

month[7] = "August";

month[8] = "September";

month[9] = "October";

month[10] = "November";

month[11] = "December";

 

  • Get the name of Months

mon = month[dateNow.getMonth()];

  • Get the current day

d = dateNow.getDate();

 

  • The year in complete format

y = dateNow.getFullYear();

 

  • Get the current hour

h = dateNow.getHours();

  • Get the current minutes

min = dateNow.getMinutes();

  • Get the seconds

sec = dateNow.getSeconds();

Declarations

w1 = "AM";

w2 = "PM";

  • hours

If (h<10) {h="0"+h;};

  • seconds

If (s<10) {s="0"+s;};

  • minutes

If (min<10) {min="0"+min;}

  • write current time in Field1(Under properties, the name of your field)

Fieldname1] = h + ":" + min + ":" + s;

  • write current date in Field2

[Fieldname2] = mon + " " + d + ", " + y;

If (h<12) {

[Fieldname1] = h + ":" + min + ":" + s + " " + w1;

}

If (h>=12) {

[Fieldname1] = h + ":" + min + ":" + s + " " + w2;

}

Related Questions