Skip to main content
Known Participant
May 23, 2019
Answered

HOW CAN I MAKE THIS A WORKING CLOCK

  • May 23, 2019
  • 1 reply
  • 476 views

   import fl.transitions.Tween;
  import fl.transitions.easing.*;
  import fl.transitions.TweenEvent;
  import flash.events.MouseEvent;
 

        {
     var mytweensec:Tween=new Tween(Sec,"rotation",None.easeNone,0,360,60,true);
     var mytweenmin:Tween=new Tween(Min,"rotation",None.easeNone,0,360,60*60,true);
     var mytweenhr:Tween=new Tween(Hr,"rotation",None.easeNone,0,360,60*60*12,true);

  mytweensec.addEventListener(TweenEvent.MOTION_FINISH,onfinish);
     mytweenmin.addEventListener(TweenEvent.MOTION_FINISH,onfinish);
     mytweenhr.addEventListener(TweenEvent.MOTION_FINISH,onfinish);
    
     }

     function onfinish(event:TweenEvent){
  event.target.start();
     }

This topic has been closed for replies.
Correct answer kglad

create 3 movieclips of the hour, minute and second hand.  orient them all to point up or north.  you can then use:

var d:Date;

this.addEventListener(Event.ENTER_FRAME,frameF);

function frameF(e:Event):void{

d=new Date();

hr.rotation = 30*(d.hours%12)+d.minutes/5;

min.rotation = 6*d.minutes;

sec.rotation = 6*d.seconds;

}

1 reply

kglad
Community Expert
Community Expert
May 23, 2019

what do you mean by a 'working clock?  do you want to display the current time based on the user's system clock?

Known Participant
May 23, 2019

yes I do

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 23, 2019

create 3 movieclips of the hour, minute and second hand.  orient them all to point up or north.  you can then use:

var d:Date;

this.addEventListener(Event.ENTER_FRAME,frameF);

function frameF(e:Event):void{

d=new Date();

hr.rotation = 30*(d.hours%12)+d.minutes/5;

min.rotation = 6*d.minutes;

sec.rotation = 6*d.seconds;

}