package {
import flash.events.Event;
import flash.display.*;
import flash.text.TextField;
import caurina.transitions.Tweener;
public class timebar extends Sprite {
public var time0:Sprite=new Sprite();
public var time1:Sprite=new Sprite();
public var time2:Sprite=new Sprite();
public var time3:Sprite=new Sprite();
public var time4:Sprite=new Sprite();
public var time5:Sprite=new Sprite();
public var timeTXT:TextField=new TextField();
public function timebar() {
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
for (var i:int = 0; i < 6; i++) {
switch (i) {
case 0 :
case 1 :
this["time"+i].graphics.beginFill(0xFF0000);
break;
case 2 :
case 3 :
this["time"+i].graphics.beginFill(0x00FF00);
break;
case 4 :
case 5 :
this["time"+i].graphics.beginFill(0x0000FF);
break;
}
this["time"+i].graphics.drawRect(0,0,1,20);
this["time"+i].graphics.endFill();
this["time"+i].x=12;
addChild(this["time" + i]);
}
time0.y=115.5;
time1.y=136.5;
time2.y=168.5;
time3.y=189.7;
time4.y=221.5;
time5.y=242.5;
addChild(timeTXT);
timeTXT.x=12;
timeTXT.y=300;
}
private function enterFrameHandler(e:Event) {
var date:Date=new Date();
date.getDate();
var h1:int=Math.floor(date.hours/10);//一桁目の取得
var h2:int=date.hours%10;//二桁目の取得
var m1:int=Math.floor(date.minutes/10);//一桁目の取得
var m2:int=date.minutes%10;//二桁目の取得
var s1:int=Math.floor(date.seconds/10);//一桁目の取得
var s2:int=date.seconds%10;//二桁目の取得
timeTXT.text=String(h1+h2+":"+m1+m2+":"+s1+s2)
Tweener.addTween(time0, {width:h1*20,time:1,transition:"liner"});
Tweener.addTween(time1, {width:h2*20,time:1,transition:"liner"});
Tweener.addTween(time2, {width:m1*20,time:1,transition:"liner"});
Tweener.addTween(time3, {width:m2*20,time:1,transition:"liner"});
Tweener.addTween(time4, {width:s1*20,time:1,transition:"liner"});
Tweener.addTween(time5, {width:s2*20,time:1,transition:"liner"});
}
}
}