forked from: flash on 2010-5-7

by aktm forked from flash on 2010-5-7 (diff: 1)
♥0 | Line 55 | Modified 2010-05-07 17:19:53 | MIT License | (replaced)
play

ActionScript3 source code

/**
 * Copyright aktm ( http://wonderfl.net/user/aktm )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/c4C3
 */

// forked from aktm's flash on 2010-5-7
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLRequest;
    
    [SWF(backgroundColor = 0xFFFFFF, width = 465, height = 465, frameRate = 1)]
    import flash.display.Loader;
    public class Main extends Sprite {
  
        private var _hari:Sprite;
		private var _hari1:Sprite;
		private var _hari2:Sprite;
		private var maru:Sprite;
		

		public function Main() {
			var loader:Loader = new Loader();
			var urlRequest:URLRequest = new URLRequest("http://assets.wonderfl.net/images/related_images/b/b0/b0eb/b0eb7d3b7ff993a44a50d08b70599b6efcfbe30e");
			loader.load(urlRequest);
			addChild(loader);

			//秒針
			_hari=new Sprite();
			_hari.graphics.beginFill(0x000000);
			_hari.graphics.drawRect(-1,-165,2,165);
			_hari.x = stage.stageWidth/2;
			_hari.y = stage.stageHeight/2;
			this.addChild(_hari);
			//時針
			_hari1 = new Sprite();
			_hari1.graphics.beginFill(0x000000);
			_hari1.graphics.drawRect(-6,-130,12,130);
			_hari1.x = stage.stageWidth/2;
			_hari1.y = stage.stageHeight/2;
			this.addChild(_hari1);
			//分針
			_hari2 = new Sprite();
			_hari2.graphics.beginFill(0x000000);
			_hari2.graphics.drawRect(-4,-150,8,150);
            _hari2.x = stage.stageWidth/2;
			_hari2.y = stage.stageHeight/2;
			this.addChild(_hari2);
			
			//中心の円
			maru = new Sprite();
			maru.graphics.beginFill(0x800000);
			maru.graphics.drawCircle(0,0,15);
			maru.graphics.endFill();
			maru.x = stage.stageWidth/2;
			maru.y = stage.stageWidth/2;
			this.addChild(maru);
			
			
			this.addEventListener(Event.ENTER_FRAME,onEnter);
			}
			private function onEnter(event:Event):void{  
               var date:Date = new Date();  
               _hari.rotation = date.getSeconds()*6; 
               _hari2.rotation = (date.getMinutes()*6)+(date.getSeconds()/10);
			   var dateHour:Number=date.getHours();
			   if (date.getHours()>=12) {
				dateHour=dateHour-12;
			}
			_hari1.rotation=(dateHour*30)+(date.getMinutes()/2);
        }
    }
}