Human Clock Event forked:29favorite:9lines:79license : MIT License modified : 2010-07-08 14:56:10 Embed Tweet package { import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.events.TimerEvent; import flash.utils.Timer; import flash.display.Graphics; import flash.display.Shape; import flash.display.Sprite; public class HumanClock extends Sprite { private var _sec:int; private var _shpSec:Shape; private var _shpMin:Shape; private var _shpHour:Shape; private var _pathCommands:Vector.<int> = Vector.<int>([1,2,2,2,2]); public function HumanClock() { initView(); var timer:Timer = new Timer(100); timer.addEventListener(TimerEvent.TIMER, onTimer); timer.start(); } private function initView():void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; var spContainer:Sprite = new Sprite; var shp:Shape; var t:Number; var layer:int; for (var i:int = 0; i < 2; ++i) spContainer.addChild(new Sprite); for (i = 0; i < 360; i += 30) { shp = new Shape; shp.graphics.beginFill(0); layer = 1; drawTrapezium(shp.graphics, 2, 16, 4, 0); shp.rotation = i; t = Math.PI / 180 * i - Math.PI / 2; shp.x = 180 * Math.cos(t); shp.y = 180 * Math.sin(t); Sprite(spContainer.getChildAt(layer)).addChild(shp); } _shpHour = new Shape; _shpHour.graphics.beginFill(0xdc143c); drawTrapezium(_shpHour.graphics, 6, 90, 10, -5); _shpHour.graphics.endFill(); _shpMin = new Shape; _shpMin.graphics.beginFill(0x228b22); drawTrapezium(_shpMin.graphics, 5, 130, 8, -5); _shpMin.graphics.endFill(); _shpSec = new Shape; _shpSec.graphics.beginFill(0xeb6101); drawTrapezium(_shpSec.graphics, 3, 150, 5, -5); _shpSec.graphics.endFill(); spContainer.x = spContainer.y = 465 >> 1; addChild(spContainer); spContainer = Sprite(spContainer.addChild(new Sprite)); spContainer.addChild(_shpHour); spContainer.addChild(_shpMin); spContainer.addChild(_shpSec); spContainer.rotation = 180; onTimer(null); } private function drawTrapezium($graphics:Graphics, $right:Number, $top:Number, $left:Number, $bottom:Number):void { $graphics.drawPath(_pathCommands, Vector.<Number>([ $left, $bottom, -$left, $bottom, -$right, $top, $right, $top, $left, $bottom ])); } private function onTimer(e:TimerEvent):void { var time:Date = new Date; var sec:int = time.getSeconds(); if (_sec == sec) return; _sec = sec; updateView(time.getHours(), time.getMinutes(), sec); } private function updateView($hour:int, $min:int, $sec:int):void { _shpHour.rotation = ($hour % 12) * 30 + $min / 2; _shpMin.rotation = $min * 6; _shpSec.rotation = _sec * 6; } } } Code Fullscreen Preview Fullscreen hacker_4z534.. xor applicott tjoen skn narutohyper motikawa_rgm.. publicroots : Human Clock xxxYukihirox.. : eventjam event jam jam_session1 Date getMinutes getHours getSeconds getChildAt addEventListener rotation graphics TimerEvent start Timer TimerEvent.TIMER time Math.PI Math.cos Vector addChild Math.sin Sprite int sort new page view favorite forked pv249 forked from: Human Clock Talent forked:0 favorite:0lines:79 (diff:1) pv344 forked from: Human Clock hacker_cm_vc89c forked:0 favorite:0lines:79 (diff:1) pv4778 ホネホネ・クロック Flash - forked from:.. chabudai forked:9 favorite:5lines:23 (diff:89) tag: codeジャナイ pv3361 鼻毛時計 chimanaco forked:0 favorite:14lines:386 (diff:513) pv4487 指描時計 forked from: Human Clock sekiryou forked:0 favorite:18lines:273 (diff:295) tag: clock pv1327 DNACLOCK Ver1(ヒトゲノムロック) OKASUKE forked:1 favorite:9lines:361 (diff:470) pv1998 役に立たない動体検知時計 mousepancyo forked:2 favorite:3lines:403 (diff:489) tag: HumanClock webCam 動体検知 微妙 pv11022 Life Clock asou_jp forked:5 favorite:64lines:435 (diff:476) tag: animation clock eizelle flexible math sperm sperma sphere uhr 夢と希望 时钟 男のロマン 衝突 1 2 3 4NEXT