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.

Working Gadget

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)

Code: vbscript
  1. Dim BDate
  2. Sub Object_OnScriptEnter
  3.     BDate = cdate("11/20/2009")
  4.     Object.SetTimer 1, 1000
  5. End Sub
  6. Sub Object_OnTimer1
  7.  
  8.  CurTime = formatdatetime(now,3)
  9.      i = DateDiff("s", Now, BDate)
  10.   DaysLeft = i \ 86400
  11.   i = i Mod 86400
  12.   HoursLeft = i \ 3600
  13.   i = i Mod 3600
  14.   MinutesLeft = i \ 60
  15.   i = i Mod 60
  16.   SecondsLeft = i
  17.   desktopx.Object("days").text = DaysLeft
  18.   desktopx.Object("hrs").text = HoursLeft
  19.   desktopx.Object("mins").text = MinutesLeft
  20.   desktopx.Object("secs").text = SecondsLeft
  21. End Sub
  22. Sub Object_OnScriptExit
  23.  object.KillTimer 1
  24. 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!



web-wc01