flash on 2010-7-6
/**
* Copyright behist ( http://wonderfl.net/user/behist )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u6Ej
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.Event;
[SWF(framelate=2, backgroundColor=0xBBDDEE)]
public class FlashTest extends Sprite {
private var back:Sprite = new Sprite;
private var circle:Sprite = new Sprite;
private var circle2:Sprite = new Sprite;
private var canvas:Sprite = new Sprite;
private var text:TextField = new TextField;
public function FlashTest() {
// write as3 code here..
var date:Date = new Date;
canvas.graphics.lineStyle(1,0x000000,0.2);
for(var min:Number = 0;min<date.minutes;min++){
for(var sec:Number = 0;sec < 60 ; sec++){
var location:Number = Math.floor(sec/6);
var rowx:Number = (min%2)*8;
var rowy:Number = min*10;
var color:Number = 0x000000 + sec*1000;// + min*10000;
canvas.graphics.moveTo(location*15 + 5 + rowx,0 + rowy);
canvas.graphics.beginFill(color,0.7);
canvas.graphics.lineTo(location*15 + rowx,5 + rowy);
canvas.graphics.lineTo(location*15 + rowx,10 + rowy);
canvas.graphics.lineTo(location*15 + 5 + rowx,15 + rowy);
canvas.graphics.lineTo(location*15 + 10 + rowx,10 + rowy);
canvas.graphics.lineTo(location*15 + 10 + rowx,5+ rowy);
canvas.graphics.lineTo(location*15 + 5 + rowx,0 + rowy);
}
}
canvas.graphics.moveTo(Math.round(date.getSeconds()/6)*15 + (date.minutes%2)*8 ,date.minutes*10);
addChild(canvas);
back.x = 350;
back.y = 150;
addChild(back);
circle.graphics.beginFill(0x222222,0.8);
circle.graphics.drawCircle(0,0,30);
back.addChild(circle);
circle2.graphics.beginFill(0xFFFFFF,1);
circle2.graphics.drawCircle(0,0,24);
back.addChild(circle2);
var max:int=12;
for (var i:Number = 0; i < 12; i++){
var canvas:Sprite = new Sprite;
var rot:Number=360*(i/max);
canvas.x = 50*Math.sin(rot*Math.PI/180);
canvas.y = 50*Math.cos(rot*Math.PI/180);
canvas.graphics.beginFill(0x000000,1.1 - i/12);
canvas.graphics.drawRect(0,0,10,20);
canvas.rotation = -rot;
back.addChild(canvas);
}
addEventListener(Event.ENTER_FRAME,enterFrame);
text.x = 300;
text.y = 50;
text.height = 20;
text.width = 200;
addChild(text);
}
private function enterFrame(e:Event):void{
var date:Date = new Date;
back.rotation = date.getSeconds()*6;
var txt:String = text.text;
text.text = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()+"."+date.getMilliseconds();
var num:Number = Math.floor(date.getSeconds()%6);
var location:Number = Math.floor(date.getSeconds()/6);
var rowx:Number = (date.minutes%2)*8;
var rowy:Number = date.minutes*10;
var color:Number = 0x000000 + date.getSeconds()*100 + date.minutes*10000;
//var check:Number = Math.round(date.getSeconds()/7);
switch(num){
case 0:
canvas.graphics.moveTo(location*15 + 5 + rowx,0 + rowy);
canvas.graphics.beginFill(color,0.7);
canvas.graphics.lineTo(location*15 + rowx,5 + rowy);
break;
case 1:
canvas.graphics.lineTo(location*15 + rowx,10 + rowy);
break;
case 2:
canvas.graphics.lineTo(location*15 + 5 + rowx,15 + rowy);
break;
case 3:
canvas.graphics.lineTo(location*15 + 10 + rowx,10 + rowy);
break;
case 4:
canvas.graphics.lineTo(location*15 + 10 + rowx,5+ rowy);
break;
case 5:
canvas.graphics.lineTo(location*15 + 5 + rowx,0 + rowy);
break;
}
}
}
}