Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How can I calculate and display the clock?

Posted on 2003-03-11
3
Medium Priority
?
184 Views
Last Modified: 2011-10-03
Hi, any idea how I can calculate the internal clock on the computer and display it in a flash movie?  Thanks.
-Mike
0
Comment
Question by:mikeplur
1 Comment
 
LVL 5

Accepted Solution

by:
ocgstyles earned 200 total points
ID: 8116470
Of course there are many ways to do this, here is one:

in frame 1 of the root timeline, I placed this script:

clock.onEnterFrame = function(){
     now = new Date();
     hh = now.getHours();
     mm = now.getMinutes();
     ss = now.getSeconds();
     
     if(ss<10){
          ss = "0" + String(ss);
     }
     if(mm<10){
          mm = "0" + String(mm);
     }
     if(hh>12){
          hh -= 12;
          ampm = "PM";
     }else{
          ampm = "AM";
     }
     clock.time = hh + ":" + mm + ":" + ss + " " + ampm;
}

I added a movieclip to the stage, named clock.  Inside that movieclip is a dynamic textfield named time.  I posted a sample (MX version) at:

http://www.elementfixe.net/ee/time.fla

enjoy!

-styles
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question