First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Buzz
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!!
» Level Intermediate

Added: 2004-12-08
Rating: 4.78 Votes: 18
(10 being the highest)
» Author
Im me
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.