Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Stub Mac Projector
DirectOS Xtra
Echo Vibes
Disable/Enable-Disk Errors,Task Switching,Screen saver,Task Bar
Domicilia
Progress Bar
MPEG Advance
SceneList
Easy Dialog
Macromedia Director 8.5 Shockwave Studio for 3D: Training from the Source
 

 

 

Behavior Clock Hands Behavior

Added on 6/7/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: PatMcClellan

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  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail