Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author Miguel Panos
»  Title: Tarta
»  Description: It is a circle graph or pie chart that takes the data entered by user
»  More by Miguel Panos


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4839 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  AuthorDeft Creative Ltd
»  Link: Home Page
»  Description: Portfolio site for .DeftCreative Ltd. A UK based web design studio specialising in flash websites, games and interactive CDROMs. With an emphasis on making things different.


Random Links | Add your own Flash Related Links
Flash Tutorials 1484 Tutorials 7 New Tutorials Added!
What's New | Top100

» Making Automatic Training Screen Capture Easily
» Create Undersea Life Animation
» Making Deinterlace Video with a low bitrate Easily
» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Interactivity

Categories Flash date/clock
Author: Buzz

 
Page 1
1

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!!

1

» Level Intermediate

Added: : 2004-12-08
Rating: 5.29 Votes: 17
Hits: 579
» Author
Im me
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments