Revision: 48647
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 7, 2011 01:48 by adrianparr
Initial Code
import flash.text.TextField; var timeTextfield:TextField = myTextFieldOnStage; timeTextfield.text = getFormattedTime(); var clockTimer:Timer = new Timer(1000, 0); clockTimer.addEventListener(TimerEvent.TIMER, onClockTimer); clockTimer.start(); function onClockTimer(e:TimerEvent):void { timeTextfield.text = getFormattedTime(); } function getFormattedTime():String { var now:Date = new Date(); var hrs:String = String(now.getHours()); if (hrs.length < 2) { hrs = "0" + hrs; } var mins:String = String(now.getMinutes()); if (mins.length < 2) { mins = "0" + mins; } return hrs + ":" + mins; }
Initial URL
Initial Description
This example expects there to be a dynamic textfield on the stage with the instance name of 'myTextFieldOnStage'. Remember to embed the fonts (Numerals and Colon).
Initial Title
AS3 Simple digital clock
Initial Tags
format
Initial Language
ActionScript 3