rajesanthu -8 Light Poster

THESE ARE THE STEPS TO FOLLOW

STEP 1. Insert 3 layers in your timeline window and name them, "background", "text"and "actions". Similar to the one shown below

STEP 2. Select Frame1 of background layer, Design the framework for your digital clock.
Select frame2 and press F5

STEP 3. Now go to Frame1 of your text layer and insert Dynamic text field in your work area. Select frame2 and press F5

To insert a Dynamic text field- Select text tool from your tool box,
Select Dynamic text from Text pop-up menu in the Property inspector.
Click on your work area wherever you want the digital clock to appear.

STEP 4. Name this Dynamic text field instance as "clock_txt"

STEP 5. Go to frame1 of actions layer. Copy and paste the below mentioned script in the action panel

time=new Date(); // time object
var seconds = time.getSeconds()
var minutes = time.getMinutes()
var hours = time.getHours()
if (hours<12) {
ampm = "AM";
} 
else{
ampm = "PM";
}
while(hours >12){
hours = hours - 12;
}
if(hours<10)
{
hours = "0" + hours;
}
if(minutes<10)
{
minutes = "0" + minutes;
}
if(seconds<10)
{
seconds = "0" + seconds;
}
clock_txt.text = hours + ":" + minutes + ":" + seconds +" "+ ampm;  

STEP 5. Now go to frame2 of actions layer and press F6 to insert a new keyframe.
Still keeping the play head on the frame2, go to action panel and copy paste the below mentioned script.

gotoAndPlay(1); 

your digital clock is ready.
Press Ctrl+Enter to view your clock.
and press ctrl+s to save the document
Try it,,,really nice
Its your friend,,,,
Rajeesh.N.Santhu

Dani AI

Generated

Nice, compact starter by . A few practical notes and a modern alternative that keep the same goal (a simple, reliable clock) but avoid common pitfalls and timeline-heavy approaches.

Browser/hosting note: Flash Player reached end-of-life in 2020 and is no longer supported in modern browsers; consider HTML/JS for web pages or a desktop runtime like Adobe AIR if you need a Flash-based app (Adobe Flash Player EOL).

Key improvements to consider:

  • Avoid forcing the main timeline to loop every frame — that wastes CPU and ties the clock to frame rate. Use a Timer (AS3) or a per-second interval instead of a timeline goto-play loop. See the AS3 Timer reference for details (Timer reference).
  • Fix 12-hour conversion edge cases: map hour 0 to 12 (midnight) and subtract 12 only when >12. The usual bug shows "00:xx" at midnight.
  • Always pad minutes/seconds to two digits for consistent display.
  • If using a dynamic text field, either use a device font or embed the numeral glyphs so digits render correctly across systems.

AS3-friendly example (use from document timeline or a document class; does not repeat the timeline loop approach):

import flash.utils.Timer;
import flash.events.TimerEvent;

var t:Timer = new Timer(1000);
t.addEventListener(TimerEvent.TIMER, onTick);
t.start();

function onTick(e:TimerEvent):void {
  var d:Date = new Date();
  var h:int = d.getHours();
  var ampm:String = (h < 12) ? "AM" : "PM";
  if (h == 0) h = 12; else if (h > 12) h -= 12;
  var m:String = (d.getMinutes() < 10) ? "0" + d.getMinutes() : d.getMinutes().toString();
  var s:String = (d.getSeconds() < 10) ? "0" + d.getSeconds() : d.getSeconds().toString();
  timeField.text = h + ":" + m + ":" + s + " " + ampm;
}

If the target is a web page today, prefer a small HTML/CSS/JS clock (JS Date API is reliable across browsers — see MDN for Date details).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.