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.
Date and Time action script
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";
Â
mon = month[dateNow.getMonth()];
d = dateNow.getDate();
Â
-
The year in complete format
y = dateNow.getFullYear();
Â
h = dateNow.getHours();
min = dateNow.getMinutes();
sec = dateNow.getSeconds();
Declarations
w1 = "AM";
w2 = "PM";
If (h<10) {h="0"+h;};
If (s<10) {s="0"+s;};
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;
}