forked from: へんなとけい
forked from へんなとけい (diff: 15)
ActionScript3 source code
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wdaG
*/
// forked from undo's へんなとけい
package
{
import flash.display.Sprite;
import flash.events.Event;
public class FlashTest extends Sprite
{
private var hor:Sprite = new Sprite();
private var min:Sprite = new Sprite();
private var sec:Sprite = new Sprite();
private var msec:Sprite = new Sprite();
private var horLength:Number = 80;
private var minLength:Number = 100;
private var secLength:Number = 120;
private var msecLength:Number = 140;
public function FlashTest()
{
// write as3 code here..
// 短針の先に長針が付いてて、長針の先に秒針がついてる
// へんな時計
//graphics.lineStyle(3,0xcccccc);
//graphics.drawCircle(stage.stageWidth/2, stage.stageHeight/2, Math.min(stage.stageWidth, stage.stageHeight)/2-50);
addChild(hor);
addChild(min);
addChild(sec);
addChild(msec);
hor.graphics.beginFill(0);
hor.graphics.drawRect(-10,10,20,-horLength-20);
hor.graphics.endFill();
min.graphics.beginFill(0x333333);
min.graphics.drawRect(-8,8,16,-minLength-16);
min.graphics.endFill();
sec.graphics.beginFill(0x999999);
sec.graphics.drawRect(-4,30,8,-secLength-30);
sec.graphics.endFill();
msec.graphics.beginFill(0xbbbbbb);
msec.graphics.drawRect(-4,30,8,-msecLength-30);
msec.graphics.endFill();
hor.x = stage.stageWidth/2;
hor.y = stage.stageHeight/2;
addEventListener(Event.ENTER_FRAME, onEnter);
}
private function onEnter(evt:Event):void
{
var date:Date = new Date();
var h:Number = date.getHours();
var m:Number = date.getMinutes();
var s:Number = date.getSeconds();
var ms:Number = date.getMilliseconds();
hor.rotation = 360*(h+m/60)/12;
min.x = hor.x + Math.sin(Math.PI*hor.rotation/180)*horLength;
min.y = hor.y - Math.cos(Math.PI*hor.rotation/180)*horLength;
min.rotation = 360*(m+s/60)/60;
sec.x = min.x + Math.sin(Math.PI*min.rotation/180)*minLength;
sec.y = min.y - Math.cos(Math.PI*min.rotation/180)*minLength;
sec.rotation = 360*(s + date.getMilliseconds()/1000)/60;
msec.x = sec.x + Math.sin(Math.PI*sec.rotation/180)*secLength;
msec.y = sec.y - Math.cos(Math.PI*sec.rotation/180)*secLength;
msec.rotation = 360*(ms)/1000;
}
}
}