GETTING DATE AND TIME VALUES IN FLASH
ActionScript date and time values make it easy to create a clock. Just retrieve the hour, minute, and second and display them on the screen and you have a real time system clock.
Use the getDay() method to retrieve the day of the week based on local time. Use the getUTCDay() method to retrieve the day of the week based on Universal Coordinated Time. The getDay() and getUTCDay() methods return 0 to represent Sunday, 1 to represent Monday, and so forth.
Use the getHours() method to retrieve the hour of the day based on local time. Use the getUTCHours() method to retrieve the hour of the day based on Universal Coordinated Time. The getHours() and getUTCHours() methods return an integer from 0 to 23. The value 0 represents midnight and the value 23 represents 11 p.m.
Use the getMinutes() method to retrieve the number of minutes that have elapsed in the current hour based on local time. Use the getUTCMinutes() method to retrieve the number of minutes that have elapsed in the current hour based on Universal Coordinated Time. The getMinutes() and getUTCMinutes() methods return an integer from 0 to 59.
Use the getSeconds() method to retrieve the number of seconds that have elapsed in the current minute based on local time. Use the getUTCSeconds() method to retrieve the number of seconds that have elapsed in the current minute based on Universal Coordinated Time. The getSeconds() and the getUTCSeconds() methods return an integer from 0 to 59.
Use the getMilliseconds() method to retrieve the number of milliseconds that have elapsed in the current second based on local time. Use the getUTCMilliseconds() method to retrieve the number of milliseconds that have elapsed in the current second based on Universal Coordinated Time. The getMilliseconds() and getUTCMilliseconds() methods return an integer from 0 to 999.
Follow the below steps:
1) Select the frame, button, or movie clip to which you want to add ActionScript.
2) Click Windows from the menu bar and then Actions to open the Actions panel.
3) Set the event to enterFrame as shown below:
onClipEvent(enterFrame){
}
4) This causes the script to execute each time the cursor enters the frame.
5) Create an instance of the Date object as shown in below example.
6) Assign the date values to variables.
7) Concatenate the values as shown below:
Example:
onClipEvent(enterFrame){
currentTime = new Date();
_root.hour = currentTime.getHours();
_root.minute = currentDate.getMinutes();
_root.second = currentDate.getSeconds();
_root.milli = currentDate.getMilliseconds();
_root.time = _root.hour+ ":" + _root.minute+ ":" + _root.second+ ":" + _root.milli;
}
8) The above code gives the values the appearance of a clock.
9) Assign concatenated values to a variable.
10) If you associate the variable with a dynamic text box, you can display the value the variable returns to the user.
11) Move to the test environment.
12) Test your movie.
13) When you enter the test environment, the screen will automatically display the time.


LinkBack URL
About LinkBacks
Reply With Quote

LinkBacks Enabled by vBSEO
Bookmarks