?
Solved

How can I calculate and display the clock?

Posted on 2003-03-11
3
Medium Priority
?
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

771 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