Creating Clock Confusion

I read a tutorial on making an analog clock in DX, but some things are just too confusing for someone just starting out. What one discribes in the tutorial on how to asseble one is confusing when your not familliar with the DX workings. I have created the four graphics needed for the clock, (hands and face). After i click on Creat new Object is where i get lost. I understand the scripting part. Am i creating a new object for each graphic? If so, do all the graphics magicaly come together when i finish the scripting? Or am i compleatly wrong? (probably)  Any help would be the greatest. Once you point me in the right direction, i'll get it.  
2,563 views 11 replies
Reply #1 Top
Yes Heir, each component is a seperate object. Then use parent/child in each objects properties/summary to bring them all together, usually the clock background is the parent for the hands etc.

Clocks are a pain in the ass but I hope this gets you started ok
Reply #2 Top
Thanks buzzh58. I will give this a try.  
Reply #3 Top
I think i better give up while i'm ahead.  
Reply #4 Top
Hello Heir, since you've already got your artwork all done follow these steps:

Create an object for each graphic (4 objects: second hand, minute hand, hour hand, clock face)

Start with the clock face. Right click on one of the objects and open Properties > Summary and name your object (clock_face or whatever you want).

Also in the summary tab set the Left and Top positions (lets say 200 left and 300 top).


Go to the States tab and under Appearance browse for your clock face graphic.

Hit apply.




Repeat those steps for the second hand, minute hand, and hour hand. Make sure you set the left and top positions to the same left and top positions of the clock face (200 left 300 top).


Now, right click on the DXBuilder icon (which should be in your system tray) and choose List Objects.

Draw a selection around all three clock hands.
Right click on this selection and choose set parent. Set the parent to the clock face.

Now select all 4 of your objects, right click, and group as "clock" (or whatever you prefer)

After that, go to the clock face Properties > General. Create a new script and paste the script below.

Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub

Sub object_ontimer1
t = FormatDateTime(time(),3)'---Get your system time

h= hour(t)'---Get current hour
desktopx.object("hour_hand").Rotation= h * 30 '---Multiply current hour to get correct rotation
m= minute(t)'---Get current minute
desktopx.object("minute_hand").Rotation= m * 6 '---Multiply current minute to get correct rotation
s= second(t)'---Get current second
desktopx.object("second_hand").Rotation= s * 6 '---Multiply current second to get correct rotation

End Sub



Hope this helps.
Reply #5 Top
This makes it clearer. It was your tutorial i was reading but it was a little confusing and it was for two global clocks. Thankyou for your help. I feal better now.  
Reply #6 Top
Great tutorial - pictures make it so much easier to follow
Reply #7 Top
Thats why i come here to WC, the pictures  I reached a snag in following the instructions. When i highlighted the hands in object navigator and set the parent to my "face clock", it worked ok. But when i highlight all four object and grouped them, it kicked out my hour hand and i got an error message when scripting that the hour hand could'not be found. I notist when it asked what method of grouping, there are three choices. I tryed all three and it still kicks out my hour hand. Any ideas?
Reply #8 Top
Ok, i figured out that i need to place the same name of my hands in the scripting as the ID name. This stoped the error message, but my hands dont work.  
Reply #9 Top
Don't ask me how or why, but i got my clock to work.  I guess the key is trial and error.  
Reply #10 Top
I guess the key is trial and error.


That's how I spend 90% of my time with DX. Soon enough things will get easier. Glad you worked everything out.  Happy DXing!
Reply #11 Top
Thats great you got it working Heir !!

- I'm the type of person that has a lot of trouble following just written directions. I'm lucky enough to have a good friend ( buzzh58 ) that will take the time to show me step by step teaching me how to do DX and other programs etc. If I am showed one step at a time , my brain usually retains the process.

So pictures with directions are the next best thing. DX is my favourite program to play with but its not easy for someone with no scripting back ground. Thank God for people that share their scripts....They make it possible for people like me that enjoy DX but will never understand scripts.