Countdown to disaster - Part 2
Making individual text objects update
Wednesday, October 29, 2008 by RomanDA | Discussion: DesktopX Tutorials
Continuing the Birthday Countdown Gadget Tutorial.
What we are going to do here is make some individual text items and place them so that they fit into our graphic.
If you look at the image below you will see "Days/hrs/min/sec" Each has its own text object.

The names are simple:
days, hrs, mins, secs
If you look at the code below you will see how we assign the info to each item:
(go back to the previous tutorial to get the details on what all this means)
- Dim BDate
- Sub Object_OnScriptEnter
- BDate = cdate("11/20/2009")
- Object.SetTimer 1, 1000
- End Sub
- Sub Object_OnTimer1
- CurTime = formatdatetime(now,3)
- i = DateDiff("s", Now, BDate)
- DaysLeft = i \ 86400
- i = i Mod 86400
- HoursLeft = i \ 3600
- i = i Mod 3600
- MinutesLeft = i \ 60
- i = i Mod 60
- SecondsLeft = i
- desktopx.Object("days").text = DaysLeft
- desktopx.Object("hrs").text = HoursLeft
- desktopx.Object("mins").text = MinutesLeft
- desktopx.Object("secs").text = SecondsLeft
- End Sub
- Sub Object_OnScriptExit
- object.KillTimer 1
- End Sub
This is the same code as in part 1, but we have removed all the "object.text" items and we now have 4 individual calls to put text into each object:
- desktopx.Object("days").text = DaysLeft
- desktopx.Object("hrs").text = HoursLeft
- desktopx.Object("mins").text = MinutesLeft
- desktopx.Object("secs").text = SecondsLeft
In each the call is VERY simple, dekxtopx.object("name").text = value
The "NAME" is the name you gave each object, and the value is what you want it to be.. VERY simple.
Yes i know this was VERY basic, but I want to do this in "steps" that others can follow.
You might also notice a small down arrow in the image. That is a button that allows me to swap the "Large" and "Mini" modes of the object. I will cover that in part 3.
Enjoy,
RomanDA
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!






