|
|
|
Clock Hands Behavior
Added on 6/7/1999
|
Clock Hands Behavior
This behavior moves Flash sprite members as the hour, minute and second hands of a radial-style clock
Requires that the sprites be imported Flash members
uses "the long time" which returns current time in format "(h)h:mm:ss am" or "(h)h:mm:ss pm"
property pHand -- which clock hand
on getPropertyDescriptionList
set handList = [#Hour, #Minute, #Second]
set p_list = [¬
#pHand: [ #comment: "Which Hand?", ¬
#format: #symbol, ¬
#default: #Second,¬
#range: handList ]]
return p_list
end
on prepareFrame me
set timeNow = the long time -- time in string format
set timeChars = the number of chars in timeNow
set secNow= value(char timeChars-4 to timeChars-3 of timeNow)
set minNow= value(char timeChars-7 to timeChars-6 of timeNow)
-- hour might be 1 digit or 2, so I delete
-- the last 9 chars of timeNow
-- which leaves either 1 or 2 digits,
-- which represent the hour
delete char timeChars-8 to timeChars of timeNow
set hourNow= value(timeNow)
-- hour could be in 24 hour format,
--which can"t be shown on radial clock
if hourNow > 12 then set hourNow = hourNow - 12
-- check to see which hand this sprite is,
-- then update its postion
case pHand of
#Second: updateSecond me, secNow
#Minute: updateMinute me, minNow, secNow
#Hour: updateHour me, hourNow, minNow
end case
end
on updateSecond me, secNow
set the rotation of sprite the spriteNum ¬
of me = secNow * 6
updateStage
end
on updateMinute me, minNow, secNow
-- secAdd allows the minute hand to move smoothly
-- in correspondence to elapsed seconds
set secAdd = secNow/10.00
set the rotation of sprite the spriteNum of me = ¬
(minNow * 6) + secAdd
updateStage
end
on updateHour me, hourNow, minNow
-- minAdd allows the hour hand to move smoothly
-- in correspondence to elapsed minutes
set minAdd = minNow/2
set the rotation of sprite the spriteNum of me = ¬
(hourNow * 30) + minAdd
updateStage
end
|
|