lcd_clock
/**
* Copyright MrKishi ( http://wonderfl.net/user/MrKishi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/r4U5
*/
package {
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.geom.ColorTransform;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.events.Event;
[SWF(width="532",height="96")]
public class LCDClock extends Sprite {
private var bitmapData:BitmapData;
private var point:Point = new Point();
private static var data:Array;
{
(function():void{
data = [];
var table:Array = [];
table[48] = [62,69,73,81,62];
table[49] = [33,127,1];
table[50] = [33,67,69,73,49];
table[51] = [66,65,81,105,70];
table[52] = [12,20,36,127,4];
table[53] = [114,81,81,81,78];
table[54] = [30,41,73,73,6];
table[55] = [64,71,72,80,96];
table[56] = [54,73,73,73,54];
table[57] = [48,73,73,74,60];
table[58] = [20];
table[65] = [63,68,68,68,63];
table[80] = [127,72,72,72,48];
table[77] = [127,32,24,32,127];
table[32] = [0];
var rect:Rectangle = new Rectangle(0, 0, 10, 10);
for (var char:String in table) {
var charData:Array = table[char];
var bmd:BitmapData = new BitmapData(charData.length*10+charData.length-1, 70+6, true, 0x00000000);
bmd.lock();
rect.x = 0;
for (var i:uint = 0; i < charData.length; i++, rect.x += 11) {
rect.y = 0;
for (var k:uint = 0; k < 7; k++, rect.y += 11) {
if (charData[i] & (64 >> k))
bmd.fillRect(rect, 0xFF00DD00);
}
}
bmd.unlock();
data[char] = bmd;
}
})();
}
public function LCDClock() {
this.bitmapData = new BitmapData(this.stage.stageWidth, this.stage.stageHeight, false, 0xFF000000);
this.addChild(new Bitmap(this.bitmapData));
this.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(e:Event):void {
var time:String = new Date().toLocaleTimeString();
this.point.x = this.point.y = 10;
this.bitmapData.lock();
this.bitmapData.colorTransform(this.bitmapData.rect, new ColorTransform(0, 0, 0, .95, 0x80, 0x30, 0x00));
for (var i:uint = 0; i < time.length; i++) {;
var src:BitmapData = data[time.charCodeAt(i)];
this.bitmapData.copyPixels(src, src.rect, point, null, null, true);
point.x += src.rect.width + 5;
}
this.bitmapData.unlock();
}
}
}