Forum Topic: Real-time Clock Tutorial

(7,915 views • 75 replies)

This topic is 3 pages long. [ 1 | 2 | 3 ]

<< < > >>
None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 10:39 AM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

<-------------------------------------------------------------->
This tutorial is very simple, any beginner flash artist can do it.
<-------------------------------------------------------------->

<-->
STEP 1
<-->
Make a symbol, and inside it, make 3 movie clips. One for the second hand, one for the minute hand, and one for the hour hand. Give the second hand an instance name of "sHand", the minute hand an instance name of "mHand", and the hour hand an instance name of "hHand". Make sure that they are centered, and that the registration point of the hands is where you want them to rotate about.

<-->
STEP 2
<-->
Place the following code in your clock symbol.:

|-----|
CODE
|-----|

onClipEvent (enterFrame) {
var my_date:Date = new Date();
hours = my_date.getHours();
minutes = my_date.getMinutes();
seconds = my_date.getSeconds();
hHand._rotation = (1/(12/(hours+minutes/60)))*360;
mHand._rotation = (1/(60/minutes))*360;
sHand._rotation = (1/(60/seconds))*360;
}

<-->
STEP 3
<-->
Edit your graphics to whatever you want them to be. You can make as many clocks as you want.
Advanced AS'ers, you can even edit the script to make a 24 hour clock or whatever you want!

<-------------------------------------------------------------->
Example Time!
<-------------------------------------------------------------->
http://img192.echo.cx/my.php?image=clock1pz.swf

<-------------------------------------------------------------->

Post your best clocks!

<-------------------------------------------------------------->
This has been a Glaiel Gamer tutorial.


None

Toast

Reply To Post Reply & Quote

Posted at: 6/21/05 10:52 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,917

What about digital clocks?


None

Flea-Productions3

Reply To Post Reply & Quote

Posted at: 6/21/05 10:59 AM

Flea-Productions3 EVIL LEVEL 08

Sign-Up: 04/13/05

Posts: 860

Here is my horrendous creation!

N00B Clock

Enjoy it.


None

KJDunwoody

Reply To Post Reply & Quote

Posted at: 6/21/05 10:59 AM

KJDunwoody LIGHT LEVEL 28

Sign-Up: 05/09/04

Posts: 3,830

Cool.
How did you come up with that?

I wish i could have.

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 11:00 AM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

Digital clocka are even easier, you just need 3 dynamic text boxes, 1 for "seconds", 1 for "minutes" and 1 for "hours"

or, here's a code for you.

onClipEvent (enterFrame) {
var my_date:Date = new Date();
hours = my_date.getHours()+1;
minutes = my_date.getMinutes()+1;
seconds = my_date.getSeconds()+1;
if(hours>12){
hours -= 12
}

disp = hours+":"+minutes+":"+seconds
}

*Remove the bold part for a 24 hour clock

Now, all you need is a dynamic text box in the clock symbol, and set the "variable" part to "disp".


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 11:01 AM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

At 6/21/05 10:59 AM, -KJDunwoody- wrote: Cool.
How did you come up with that?

I wish i could have.

My next game has unlockable "toys" and I decided to put a clock as one. So I did a tiny bit of work and came up with this.


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 11:05 AM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

Here's a better code for a digital clock, mistake in the first one.
onClipEvent (enterFrame) {
var my_date:Date = new Date();
hours = my_date.getHours();
minutes = my_date.getMinutes();
seconds = my_date.getSeconds();
if (hours>12) {
hours -= 12;
}
if (seconds<10) {
seconds = "0"+seconds;
}
if (minutes<10) {
minutes = "0"+minutes;
}
if (hours<10) {
hours = "0"+hours;
}
disp = hours+":"+minutes+":"+seconds;
}


None

KJDunwoody

Reply To Post Reply & Quote

Posted at: 6/21/05 11:14 AM

KJDunwoody LIGHT LEVEL 28

Sign-Up: 05/09/04

Posts: 3,830

At 6/21/05 11:01 AM, Glaiel_Gamer wrote: My next game has unlockable "toys" and I decided to put a clock as one. So I did a tiny bit of work and came up with this.

Cool.
Do you have hotmail?

I would like to talk to you.

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 11:20 AM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

I have AIM, KingGoboWoboFaun
glaielgamesmail@comcast.net


None

liaaaam

Reply To Post Reply & Quote

Posted at: 6/21/05 11:21 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,534

At 6/21/05 11:01 AM, Glaiel_Gamer wrote: My next game has unlockable "toys" and I decided to put a clock as one. So I did a tiny bit of work and came up with this.

Last time I saw that, it was looking good. Hows it coming along?


None

KJDunwoody

Reply To Post Reply & Quote

Posted at: 6/21/05 11:24 AM

KJDunwoody LIGHT LEVEL 28

Sign-Up: 05/09/04

Posts: 3,830

At 6/21/05 11:20 AM, Glaiel_Gamer wrote: I have AIM, KingGoboWoboFaun

AIM isn't Good enough BITCH!

Because I don't have it.

None

Glaiel-Clock

Reply To Post Reply & Quote

Posted at: 6/21/05 11:26 AM

Glaiel-Clock EVIL LEVEL 03

Sign-Up: 01/08/05

Posts: 14

OH CRAP I FORGOT TO MENTION SOMETHING!
IN your hand symbols MAKE SURE THAT THEY ARE POINTING AT THE 12!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!
(This is my rarely-used alt account)

DEADSiM2, I have 5/13 games and 8/20 toys completed.


None

Toast

Reply To Post Reply & Quote

Posted at: 6/21/05 11:30 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,917

Isn't it forbidden to have an alt account?


None

I-Jaf

Reply To Post Reply & Quote

Posted at: 6/21/05 11:36 AM

I-Jaf EVIL LEVEL 09

Sign-Up: 07/02/03

Posts: 4,256

You know there's a clock in the samples?


None

liaaaam

Reply To Post Reply & Quote

Posted at: 6/21/05 11:38 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,534

At 6/21/05 11:30 AM, Dark_Toaster wrote: Isn't it forbidden to have an alt account?

No, just to use the alt account to get around bans.


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 02:00 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

At 6/21/05 11:36 AM, JafitMan wrote: You know there's a clock in the samples?

I don't care.


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/21/05 10:55 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

That post needed to be posted, though. It was VERY important.


None

Denvish

Reply To Post Reply & Quote

Posted at: 6/27/05 03:45 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

At 6/21/05 10:39 AM, Glaiel_Gamer wrote: <-------------------------------------------------------------->
This has been a Glaiel Gamer tutorial.

lol. This looks VERY similar to a dial clock AS snippet I created and posted a little while ago, even down to the Instance Names... nvm, it's all good =)

- - Flash - Music - Images - -

BBS Signature

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/28/05 02:18 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

really? Hmm... I never saw that topic.....


None

speddyfeddy1234

Reply To Post Reply & Quote

Posted at: 6/28/05 03:31 PM

speddyfeddy1234 NEUTRAL LEVEL 03

Sign-Up: 02/23/05

Posts: 318

riiiight, :p jp


None

Denvish

Reply To Post Reply & Quote

Posted at: 6/28/05 03:35 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

At 6/28/05 02:18 PM, Glaiel_Gamer wrote: really? Hmm... I never saw that topic.....

Just checked, it's not quite the same. I made it for AngelClock quite a while ago, didn't realise there was one in the Flash sample files...

http://www.newgrounds.com/bbs/topic.php?id=284910

- - Flash - Music - Images - -

BBS Signature

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/28/05 03:37 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

ok. I didn't realize there was one in there either. Oh well.


None

speddyfeddy1234

Reply To Post Reply & Quote

Posted at: 6/28/05 03:38 PM

speddyfeddy1234 NEUTRAL LEVEL 03

Sign-Up: 02/23/05

Posts: 318

Yay, now we all are friends again! Lets look for treasure!


None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 03:42 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

At 6/28/05 03:38 PM, speddyfeddy1234 wrote: Yay, now we all are friends again! Lets look for treasure!

Inglor.onReadJackshit=func(content);

function func(content):Punch{
if(Content.Spamness>5){
content.Spamness--;
func(content);
return Punch;
}
}

this is what you get, 8 punches, if you know what this means, I'll take that back :P


None

Denvish

Reply To Post Reply & Quote

Posted at: 6/28/05 03:51 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,236

No, no, no, you got it all wrong...

Denvish.onReadJackshit=func(content);

function func(content):Ban{
if(content.Spamness>5){
content.Spamness--;
func(content);
return Ban;
}
}

lol@stealing code

- - Flash - Music - Images - -

BBS Signature

None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 03:57 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

nice stealing :)

but got it wrong , you just banned him alot of times (recursion tutorial coming soon)

Denvish.onReadJackshit=func(content.Spamness);

function func(content):Number{
Spamness=Spamness*(Spamness>12)+7*(Spamness>12);
if(Spamness>5){
return Spamness+func(Spamness-1);
}
return 0;
}

This actually bans him for a day for each Spamness >5 and maxs at 7 days

I love recursive stuff :)


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/28/05 03:58 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

Or

GG.onReadJackshit=func(content);

function func(content):nothing{
if(content.Spamness>5){
content.Spamness--;
func(content);
return nothing; // I have no mod powers
}
}


None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/28/05 04:01 PM

Glaiel-Gamer NEUTRAL LEVEL 27

Sign-Up: 12/28/04

Posts: 8,042

At 6/28/05 03:57 PM, Inglor wrote: nice stealing :)

but got it wrong , you just banned him alot of times (recursion tutorial coming soon)

Denvish.onReadJackshit=func(content.Spamness);

function func(content):Number{
Spamness=Spamness*(Spamness>12)+7*(Spamness>12);
if(Spamness>5){
return Spamness+func(Spamness-1);
}
return 0;
}

This actually bans him for a day for each Spamness >5 and maxs at 7 days

I love recursive stuff :)

If you love recursion so much, try this

function hurt(username){
username.punch
if(modpower){
username.ban
}
hurt(username)
}
hurt("speddyfeddy1234")


None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 04:02 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

oops, I made a baddy :P

Denvish.onReadJackshit=Ban(content);

function Ban(content):BanType{
return "You have been banned for" + func(content.Spamness) + "Days, Reason:"+content;
}
function func(Spamness):Number{
Spamness=Spamness*(Spamness>12)+7*(Spamness>12);
if(Spamness>5){
return Spamness+func(Spamness-1);
}
return 0;
}


None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 04:04 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

GG didn't get the recursive function calling either, but oh well ;) like i said, tutorial coming soon ;)


All times are Eastern Standard Time (GMT -5) | Current Time: 02:22 PM

<< Back

This topic is 3 pages long. [ 1 | 2 | 3 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!