わかりにくいけど時計
時計です。
曜日によって背景が変わります。
わかりにくくてすいません。
/**
* Copyright peso ( http://wonderfl.net/user/peso )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5Dge
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
public class clock extends Sprite
{
private var array_h:Array = new Array;
private var array_m:Array = new Array;
private var array_s:Array = new Array;
private var array_ms:Array = new Array;
public function clock()
{
makeObj();
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void{
var date:Date = new Date();
var ms:int = date.milliseconds / 100 + 1;
var s:int = date.seconds + 1;
var m:int = date.minutes + 1;
var h:int = date.hours + 1;
if(ms==1){
for(var ms1:uint = 1; ms1<10; ms1++){
array_ms[ms1].visible = false;
}
}
else{
for(var ms2:uint = 0; ms2<ms; ms2++){
array_ms[ms2].visible = true;
}
}
if(s==1){
for(var s1:uint = 1; s1<60; s1++){
array_s[s1].visible = false;
}
}
else{
for(var s2:uint = 0; s2<s; s2++){
array_s[s2].visible = true;
}
}
if(m==1){
for(var m1:uint = 1; m1<60; m1++){
array_m[m1].visible = false;
}
}
else{
for(var m2:uint = 0; m2<m; m2++){
array_m[m2].visible = true;
}
}
if(h==1){
for(var h1:uint = 1; h1<12; h1++){
array_h[h1].visible = false;
}
}
else if(h==13){
for(var h2:uint = 1; h2<12; h2++){
array_h[h2].visible = false;
}
}
else if(h>1 && h<13){
for(var h3:uint = 0; h3<h; h3++){
array_h[h3].visible = true;
}
}
else{
for(var h4:uint = 0; h4<h-12; h4++){
array_h[h4].visible = true;
}
}
}
private function makeObj():void{
var date:Date = new Date();
var rad_h:Number = 0;
var rad_m:Number = 0;
var rad_s:Number = 0;
var rad_ms:Number = 0;
var rotation_ms:uint = 0;
var rotation_s:uint = 0;
var rotation_m:uint = 0;
var rotation_h:uint = 0;
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
var sp_b:Sprite = new Sprite();
if(date.day==0){
sp_b.graphics.beginFill(0xFF8000, 0.5);
}
else if(date.day==1){
sp_b.graphics.beginFill(0xFFFF00, 0.5);
}
else if(date.day==2){
sp_b.graphics.beginFill(0xFF0000, 0.5);
}
else if(date.day==3){
sp_b.graphics.beginFill(0x00E0E0, 0.5);
}
else if(date.day==4){
sp_b.graphics.beginFill(0x00E000, 0.5);
}
else if(date.day==5){
sp_b.graphics.beginFill(0xE0E000, 0.5);
}
else if(date.day==6){
sp_b.graphics.beginFill(0x0000FF, 0.5);
}
sp_b.graphics.drawRect(centerX-stage.stageWidth/2, centerY-stage.stageHeight/2, stage.stageWidth, stage.stageHeight);
sp_b.graphics.endFill();
addChild(sp_b);
for(var l:uint = 0; l<10; l++){
var sp_ms:Sprite = new Sprite();
sp_ms.graphics.beginFill(0x000000, 1);
sp_ms.graphics.drawRect(0, 0, 4, 20);
sp_ms.graphics.endFill();
rad_ms = Math.PI / 180 * (l * 36 - 90);
sp_ms.x = centerX + 40 * Math.cos(rad_ms);
sp_ms.y = centerY + 40 * Math.sin(rad_ms);
sp_ms.rotation = rotation_ms;
array_ms.push(sp_ms);
addChild(sp_ms);
if(l!=0){
sp_ms.visible = false;
}
rotation_ms += 36;
}
for(var i:uint = 0; i<60; i++){
var sp_s:Sprite = new Sprite();
sp_s.graphics.beginFill(0x000000, 1);
sp_s.graphics.drawRect(0, 0, 4, 40);
sp_s.graphics.endFill();
rad_s = Math.PI / 180 * (i * 6 - 90);
sp_s.x = centerX + 85 * Math.cos(rad_s);
sp_s.y = centerY + 85 * Math.sin(rad_s);
sp_s.rotation = rotation_s;
array_s.push(sp_s);
addChild(sp_s);
if(i!=0){
sp_s.visible = false;
}
rotation_s += 6;
}
for(var j:uint = 0; j<60; j++){
var sp_m:Sprite = new Sprite();
sp_m.graphics.beginFill(0x000000, 1);
sp_m.graphics.drawRect(0, 0, 4, 40);
sp_m.graphics.endFill();
rad_m = Math.PI / 180 * (j * 6 - 90);
sp_m.x = centerX + 130 * Math.cos(rad_m);
sp_m.y = centerY + 130 * Math.sin(rad_m);
sp_m.rotation = rotation_m;
array_m.push(sp_m);
addChild(sp_m);
if(j!=0){
sp_m.visible = false;
}
rotation_m += 6;
}
for(var k:uint = 0; k<12; k++){
var sp_h:Sprite = new Sprite();
sp_h.graphics.beginFill(0x000000, 1);
sp_h.graphics.drawRect(0, 0, 4, 40);
sp_h.graphics.endFill();
rad_h = Math.PI / 180 * (k * 30 - 90);
sp_h.x = centerX + 175 * Math.cos(rad_h);
sp_h.y = centerY + 175 * Math.sin(rad_h);
sp_h.rotation = rotation_h;
array_h.push(sp_h);
addChild(sp_h);
if(k!=0){
sp_h.visible = false;
}
rotation_h += 30;
}
}
}
}