00:00
00:00
B1KMusic
Hi. I make games and software. I'm not on NG much, but feel free to peruse my youtube and gitlab for interesting stuff.

Braden @B1KMusic

Age 29, Male

Programmer/Musician/

fish

Earth, Milky Way

Joined on 6/19/11

Level:
10
Exp Points:
948 / 1,110
Exp Rank:
69,557
Vote Power:
5.20 votes
Rank:
Police Sergeant
Global Rank:
8,626
Blams:
42
Saves:
1,040
B/P Bonus:
12%
Whistle:
Normal
Medals:
799

Working Digital Clock :D

Posted by B1KMusic - August 19th, 2011


I just made a slightly newer version of the clock and a 3D version...

Color-changer clock (press C to turn color changing on, and 0-9 to change color)

3D(ish) clock

//init
n1.gotoAndStop("n8");
n2.gotoAndStop("n8");
n3.gotoAndStop("n8");
n4.gotoAndStop("n8");
//end init
onEnterFrame = function () {
now = new Date();
h = now.getHours();
m = now.getMinutes();
//hours
if (h == 0 || h == 12) {
n1.gotoAndStop("n1");
n2.gotoAndStop("n2");
} else if (h == 1 || h == 13) {
n1.gotoAndStop("n0");
n2.gotoAndStop("n1");
} else if (h == 2 || h == 14) {
n1.gotoAndStop("n0");
n2.gotoAndStop("n2");
} else if (h == 3 || h == 15) {
n1.gotoAndStop("n0");
n2.gotoAndStop("n3");
} else if (h == 4 || h == 16) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n4');
} else if (h == 5 || h == 17) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n5');
} else if (h == 6 || h == 18) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n6');
} else if (h == 7 || h == 19) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n7');
} else if (h == 8 || h == 20) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n8');
} else if (h == 9 || h == 21) {
n1.gotoAndStop('n0');
n2.gotoAndStop('n9');
} else if (h == 10 || h == 22) {
n1.gotoAndStop('n1');
n2.gotoAndStop('n0');
} else if (h == 11 || h == 23) {
n1.gotoAndStop('n1');
n2.gotoAndStop('n1');
}
//minutes
//tens
if (m<10) {
n3.gotoAndStop('n0');
} else if (m<20) {
n3.gotoAndStop('n1');
} else if (m<30) {
n3.gotoAndStop('n2');
} else if (m<40) {
n3.gotoAndStop('n3');
} else if (m<50) {
n3.gotoAndStop('n4');
} else {
n3.gotoAndStop('n5');
}
function mn(t) {
//mn = MiNutes
//t = time
n4.gotoAndStop(t);
}
//ones
if (m == 0 || m == 10 || m == 20 || m == 30 || m == 40 || m == 50) {
mn('n0');
} else if (m == 1 || m == 11 || m == 21 || m == 31 || m == 41 || m == 51) {
mn('n1');
} else if (m == 2 || m == 12 || m == 22 || m == 32 || m == 42 || m == 52) {
mn('n2');
} else if (m == 3 || m == 13 || m == 23 || m == 33 || m == 43 || m == 53) {
mn('n3');
} else if (m == 4 || m == 14 || m == 24 || m == 34 || m == 44 || m == 54) {
mn('n4');
} else if (m == 5 || m == 15 || m == 25 || m == 35 || m == 45 || m == 55) {
mn('n5');
} else if (m == 6 || m == 16 || m == 26 || m == 36 || m == 46 || m == 56) {
mn('n6');
} else if (m == 7 || m == 17 || m == 27 || m == 37 || m == 47 || m == 57) {
mn('n7');
} else if (m == 8 || m == 18 || m == 28 || m == 38 || m == 48 || m == 58) {
mn('n8');
} else if (m == 9 || m == 19 || m == 29 || m == 39 || m == 49 || m == 59) {
mn('n9');
}
};

A new section I added for pointless frills is this:

//Color
col1 = new Color(n1);
col2 = new Color(n2);
col3 = new Color(n3);
col4 = new Color(n4);
colc = new Color(C);
colt = new Color(CT)
red = 0xCC0000;
blue = 0x0000CC;
green = 0x00CC00;
yellow = 0xFFCC00;
black = 0x000000;
function colset(c) {
col1.setRGB(c);
col2.setRGB(c);
col3.setRGB(c);
col4.setRGB(c);
colc.setRGB(c);
}
O = {};
Key.addListener(O);
O.onKeyDown = function() {
KEY = Key.getCode();
if (KEY == key.C && !Cv) {
Cv = true;
CT.text = "COLOR MODE: ON"
colt.setRGB(0x00CC00)
} else if (KEY == key.C && Cv) {
Cv = false;
CT.text = "COLOR MODE: OFF"
colt.setRGB(0xCC0000)
}
if (Cv) {
if (KEY == key.ONE) {
colset(blue);
} else if (KEY == key.TWO) {
colset(red);
} else if (KEY == key.THREE) {
colset(green);
} else if (KEY == key.FOUR) {
colset(yellow);
} else if (KEY == key.FIVE) {
colset(black);
} else if (KEY == key.SIX) {
colset(0xCCCCCC);
} else if (KEY == key.SEVEN) {
colset(0xAAAAAA);
} else if (KEY == key.EIGHT) {
colset(0x888888);
} else if (KEY == key.NINE) {
colset(0x666666);
} else if (KEY == key.ZERO) {
colset(0xFFFFFF);
}
}
};

Wasn't nearly as tedious.

col1-4 define each of the numbers, colc defines the colon in the center, colt changes the text's color to give the On and Off indicators more of a visual cue.

red, blue, yellow, etc. defines the colors, this step isn't really that necessary, but it makes life easier

function colset just makes it so I don't have to type a million lines to change the color

O = {}, Key.addlistener(O) and O.onKeyDown create a key listening event

all the rest ias pretty self-explanatory.


Comments

Comments ain't a thing here.