• 钟表效果


    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;
    		}
    
    	}
    }
    
    

  • 相关阅读:
    MySQL中的排序
    为什么删除记录表文件不会减小?(记录的插入与删除在磁盘上的变化)
    Mysql 中的MDL
    Redis 基础知识点总结
    分布式系统中的CAP理论与Base理论
    Java基础篇(JVM)——Class对象
    Java基础篇(JVM)——类加载机制
    Java基础篇(JVM)——总领
    数据结构与算法小结——排序(八)
    数据结构与算法小结——排序(七)
  • 原文地址:https://www.cnblogs.com/sinsoul/p/1876444.html
Copyright © 2020-2023  润新知