Analog clock

Well I was just sitting here looking through some of the tuts, when all of a sudden I just “saw” the easiest way to make an analog clock! =)

Wasn’t really thinking about it, it just came outta nowhere… scary… :-\

see, just make your, umm… uhh… the stick that shows the position… say noon (12 AM) make it point upwards, fiddle with the center of it, and throw it into some sorta clock thingy circle (make suer u name the instance, I called mine “showsec”)… u know what I mean…

then have two frames on your main stage, make an “actions” layer, with frame 2 having a “gotoandplay 1”. THEN, simply type in this for frame 1: (using seconds here)

mytime = new date();
seconds = mytime.getseconds();
setProperty("_root.showsec", _rotation, sec*6);

and that’s it!! =)

For minutes just alter the variable “seconds” to: mytime.getminutes()

and so on… easy huh! :evil:

sorry, minor correction.

setProperty(“hour”, _rotation, (hour2*30)+((minute/60)*30));

heres the code for the hour show… here I just called the “mytime=.gethours()” for “hour2”

I added the “((minute/60)*30))” so we’d get the numbers between the hours aswell, otherwise it would stay on one hour number until it changed… that would then be an hour… before it changes… get it? This way it updates with every minute-shift…

=)

There… made it…

take a gander:

http://www.avalon-rev.dk/html/clock.html (Site’s not up anymore)

If anybode happens to want the fla, just reply here… if anybode want’s it, i’ll upload for others to download. =)

Nice, Eilsoe (nice name!), but as a matter of fact, we already had a tute about that on this site :slight_smile: Anyway, there’s another way to do that with setInterval but it’s a bit more complicated.

pom :asian:

hey pom.

yearh I know theres another way :slight_smile:

But as u said: “more complicated”… this is just an easier way to do it… u know, for people like me (I’m an idiot when it comes to AS)… lol

and it works… so… anyway… mybe people will use this method 2… i hope… let’s just call it a “tip” …k? :slight_smile:

Something else: your syntax and the fact that you use 2 frames are Flash 4… Better try it the Flash 5 way. OnClipEvent handlers, and dot syntax.

pom :asian:

Here E–

http://www.kirupa.com/developer/actionscript/clock.asp

check that out to update your code.

thanx jubba… i’ll try that…

one more thing… how would you make it do a “tick-tock” sound…?

I guess that would only work on my example, since it actually moves on only 60 positions instead of your 360…

how can that sound be made…? alternating “tick tock” on move…?

here, I made this with the on(enterframe) thingy… it worked! :slight_smile:

http://www.avalon-rev.dk/html/clock2.html

plus some cleaner gfx… =)

How do’ya like THIS then…? heheh…

figured out a way to make that “tick tock” sound!! =)

See, I take the getseconds(); as a variable “sec”. Then run an:

if (sec%2 == 0) , play some sound (tick)
else, play some other sound (tock)

(%) = modula

if it somes out as “0”, it’s an even number. If it comes out as “1”, it’s an odd number…

simple! :slight_smile:

Weird, nobody posts this as a tute anywhere… not even in the flash help…

well, now i’m proud of myself… lol :stuck_out_tongue: