package { import flash.display.Shape; import flash.events.TimerEvent; import flash.text.TextField; import flash.utils.Timer; import flash.display.Sprite; /* *author : SinSoul *blogs: http://www.cnblogs.com/sinsoul */ public class kk extends Sprite { var faces:Shape; var hour:Shape; var minute:Shape; var second:Shape; var timer:Timer=new Timer(1000); //var hd:Number; public function kk() { init(); initstate(); timer.addEventListener(TimerEvent.TIMER,ll); timer.start(); } function init() { faces=new Shape(); hour=new Shape(); minute=new Shape(); second=new Shape(); faces.graphics.lineStyle(5,0xff0000,0.3); faces.graphics.beginFill(0xffff35,0.8); faces.graphics.drawCircle(275,200,120); addChild(faces); minute.graphics.lineStyle(3,0x456123,0.9); minute.graphics.moveTo(0,0); minute.graphics.lineTo(0,-80); addChild(minute); second.graphics.lineStyle(1,0x456879,0.6); second.graphics.moveTo(0,0); second.graphics.lineTo(0,-100); addChild(second); hour.graphics.lineStyle(5,0xff0000,0.9); hour.graphics.moveTo(0,0); hour.graphics.lineTo(0,-50); addChild(hour); hour.x=275; hour.y=200; minute.x=275; minute.y=200; second.x=275; second.y=200; for (var i:int=1; i<13; i++) { var txt:TextField=new TextField(); txt.text=String(i); txt.x=Math.cos(Math.PI*2/12*i-Math.PI/2)*115+269; txt.y=Math.sin(Math.PI*2/12*i-Math.PI/2)*115+190; addChild(txt); } } function initstate() { var date:Date=new Date(); hour.rotation=date.hours*30+date.minutes*0.5; minute.rotation=date.minutes*6+date.seconds*0.1; second.rotation=date.seconds*6 ; } function ll(e:TimerEvent) { var date:Date=new Date(); hour.rotation=date.hours*30+date.minutes*0.5; minute.rotation=date.minutes*6+date.seconds*0.1; second.rotation=date.seconds*6; } } }