Forked from: awef's 不正確時計 diff:1 forked from: 不正確時計 motioneditor.. forked:0favorite:0lines:56license : MIT License modified : 2010-01-03 20:02:19 Embed Tweet // forked from awef's 不正確時計 // forked from awef's flash on 2009-03-18 //不正確な時計です。 //本当の時間の前後5分以内を示します。 package { import flash.display.Sprite; public class main extends Sprite { function main() { stage.addChild(new clock(stage.stageWidth / 2, stage.stageHeight / 2, 128)); } } } import flash.display.Sprite; class clock extends Sprite { private var r:uint; private var gap : int; function clock(arg_x:int, arg_y:int, arg_r:uint) { x = arg_x; y = arg_y; r = arg_r; gap = -5 + Math.random() * 10; alpha = 0.5; var tmp:Sprite; tmp = new Sprite(); tmp.graphics.lineStyle(2, 0x000000); tmp.graphics.drawCircle(0, 0, r); addChild(tmp); tmp = new Sprite(); tmp.graphics.beginFill(0x000000); tmp.graphics.drawRect(0 - 1, 0, 2, -r / 10 * 9); tmp.graphics.endFill(); tmp.name = "s"; addChild(tmp); tmp = new Sprite(); tmp.graphics.beginFill(0x000000); tmp.graphics.drawRect(0 - 2, 0, 4, -r / 10 * 9); tmp.graphics.endFill(); tmp.name = "m"; addChild(tmp); tmp = new Sprite(); tmp.graphics.beginFill(0x000000); tmp.graphics.drawRect(0 - 2, 0, 4, -r / 10 * 8); tmp.graphics.endFill(); tmp.name = "h"; addChild(tmp); addEventListener(Event.ENTER_FRAME, frame); } private function frame(e:Event):void { var d:Date = new Date(); getChildByName("s").rotationZ = d.seconds * 6; getChildByName("m").rotationZ = (d.minutes + gap) * 6; getChildByName("h").rotationZ = d.hours % 12 * 30 + d.minutes / 2; } } Code Fullscreen Preview Fullscreen