Display time
This Flash tutorial will teach you how to display the time in Actionscript 2.0. The time function is taken directly from the system clock on your machine.
UPDATE: new Actionscript 3.0 version now available here.
Display Time
Step 1
Create a new Flash document.
Using the dynamic text tool drag a rectangle shapes on the stage like below:
Step 2
Using the selecting tool (v) select the dynamic text box. And then give it a variable name. eg. theTime.
Step 3
Convert the dynamic text box into a movie clip by selecting F8, choose an appropriate name and click ok.
Step 4
Now right click on your movie clip and select Actions.
Add the following code:
onClipEvent (enterFrame) {
myTime = new Date();
theSeconds = myTime.getSeconds();
theMinutes = myTime.getMinutes();
theHours = myTime.getHours();
if (theHours>=12) {
ampm = "pm";
} else {
ampm = "am";
}
if (theHours>=13) {
nHours = nHours-12;
}
if (length(theMinutes) == 1) {
theMinutes = "0" +theMinutes;
}
if (length(theSeconds) == 1) {
theSeconds = "0"+theSeconds;
}
theTime = theHours+":"+theMinutes+":"+theSeconds+" " +ampm;
}
Step 5
Test your movie Ctrl + Enter.
You should now have a time display.







1 comments:
gr8 work...
Post a Comment