|
|
Search Tutorials
As far as I am aware this works in most versions of Flash, but I used Flash MX 2004 to create a dynamic text field and give it an instance name (eg. clock). Then just copy and paste the script below: stop(); _root.onEnterFrame = function() { //The current time is taken from the computers clock, and should technically work in all time zones myDate_date = new Date(); currentHour = myDate_date.getHours(); currentMinute = myDate_date.getMinutes(); //Makes sure the clock stay in 24hr format, for a 12hr clock simply change 24 to 12 if (currentHour>24) { currentHour = currentHour-24; } else if (currentHour == 0) { currentHour = 24; } //Whith out this part the hours before 10 will appear as 9 not 09!! if (currentHour<10) { currentHour = "0"+currentHour; } //Whith out this part the minutes before 10 will appear as 9 not 09!! if (currentMinute<10) { currentMinute = "0"+currentMinute; } //Arrays to create days and months, for other languages simply put in the translations daysofWeek_array = new Array(); daysofWeek_array[0] = "Sunday"; daysofWeek_array[1] = "Monday"; daysofWeek_array[2] = "Tuesday"; daysofWeek_array[3] = "Wednesday"; daysofWeek_array[4] = "Thursday"; daysofWeek_array[5] = "Friday"; daysofWeek_array[6] = "Saturday"; daysofMonth_array = new Array(); daysofMonth_array[0] = "January"; daysofMonth_array[1] = "February"; daysofMonth_array[2] = "March"; daysofMonth_array[3] = "April"; daysofMonth_array[4] = "May"; daysofMonth_array[5] = "June"; daysofMonth_array[6] = "July"; daysofMonth_array[7] = "August"; daysofMonth_array[8] = "September"; daysofMonth_array[9] = "October"; daysofMonth_array[10] = "November"; daysofMonth_array[11] = "December"; //The current date is taken from the computers clock myDate_date = new Date(); currentYear = myDate_date.getFullYear(); currentMonth = myDate_date.getMonth(); currentDate = myDate_date.getDate(); currentDay = myDate_date.getDay(); //this is how all the information is displayed in the dynamic tex field //if your text field is not called 'clock' change clock.text to 'instancename.text' clock.text = myDisplay_txt.text=""+daysofWeek_array[currentDay]+", "+daysofMonth_array[currentMonth]+" "+currentDate+", "+currentYear+" "+currentHour+":"+currentMinute+""; }; simple!!
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|