Subject: RE: Thunderdome: silly clock problem Date: Mon, 14 Jan 2002 14:32:18 -0500 From: "Wil Dalphin" To: "external_thunderdome adobe.com" Hi Simon, It looks from your code as if you have each hand animated in the timeline, and are attempting to make it go to a specific point in the animation on each frame. One problem with this is that our export will add frames to make animation run more smoothly. The reason your minute and second hands are only getting to 6 is because you are telling them to go up to 60 frames, and apparently 60 frames only gets you to the 6. If you count the seconds that pass, it takes 30 seconds for the second hand to reach the 15. So, you've probably got twice as many frames as you think you have, and just need to multiply by 2 in your code, or cut the keyframes in half in your timeline. Another thing I notice is you are calling "Number(hour+movement)". Number returns a boolean value (1 or 0), which means your hour is always going to be 1 or 0. This is why your hour hand is never going to move. I've done a couple clocks in the past, and have found that the most simplistic way to handle it is to make each hand a movieclip pointing at 12 when it's rotation is 0, and then in the onEnterFrame handler I put this code... var now = new Date(); _root.timers.hours._rotation = now.getHours() * 30 + (now.getMinutes() / 2); _root.timers.minutes._rotation = now.getMinutes() * 6; _root.timers.seconds._rotation = now.getSeconds() * 6; In this example, "timers" is a group containing all 3 movieclips, "hours", which is the mc of the hour hand, "minutes", "seconds", etc you get the picture. Sincerely, Wil D. > -----Original Message----- > Not sure what's wrong with this script for an analog clock. It > previews well > in LM2, but displays incorrect time once previewed in a browser: > > ______________________________________________________ > MyDate = new Date(); > hour = MyDate.getHours(); > minute = MyDate.getMinutes(); > second = MyDate.getSeconds(); > if (hour> 11) { > hour = hour-12; > } > hour = hour*5; > movement = minute/12; > hour = Number(hour+movement); > with (_root.Clock.Hours) { > _root.Clock.Hours.gotoAndStop(hour) + 1; > } > with (_root.Clock.Minutes) { > _root.Clock.Minutes.gotoAndStop(minute) + 1; > } > with (_root.Clock.Seconds) { > _root.Clock.Seconds.gotoAndStop(second) + 1; > } > _______________________________________________________ > > Clock hands are alligned at 12 oclock, any feedback would be appreciated. > > Here's an example: http://forums.livemotionstudio.com/weirdclock.swf