Merry DXmas!
Holiday-themed tutorials
Friday, December 19, 2008 by sViz | Discussion: DesktopX Tutorials
![]()
It's the holidays and I feel like sharing. Below are four quick, do-it-yourself tutorials based on my all-time favorite Christmas DesktopX widgets. Enjoy!
Is It Christmas Yet?
I absolutely love RomanDA's Christmas Countdown Snowglobe widget. It's practical, compact, and the graphics are stellar. Did I mention it has animated snow?
You might be wondering, "How can I make a countdown widget to New Year's" or "How can I make a countdown widget to Uncle Bob's birthday--no screw Uncle Bob (he gives lousy gifts)--how 'bout a countdown to the Superbowl?!"
Well, I'm pleased to say, it's not hard at all.
Concept
The concept is pretty straightforward. You need to mark what day it is, mark what day you're counting down to, and calculate how much time remains between the two dates.
Dday - Today = time remaining. It's simple and there's actually a vbscript function that does this. It's called DATEDIFF (google it.)
Execution
Keeping it simple, we'll create a display text, which will show us the days remaining (or hours, minutes, and seconds if that's what floats your boat.)
Insert this script into your text object:
Dim Ddaytxt, Dday
Sub Object_OnScriptEnter
Dday = "1/1/2009"
Ddaytxt = "New Year's Day"
Object.settimer 1, 1000 ' -one-second timer
End Sub
Sub Object_OnTimer1
Sremain = DateDiff("s", Now(), Dday) '—seconds
Minremain = DateDiff("n", Now(), Dday) '--minutes
Hremain = DateDiff("h", Now(), Dday) '--hours
Dremain = DateDiff("d", Now(), Dday) '--days
Mremain = DateDiff("m", Now(), Dday) '--months
Yremain = DateDiff("y", Now(), Dday) '--years
Newmsg = Dremain & " day(s) until " & Ddaytxt
If Newmsg <> object.text Then Object.text = Newmsg
End Sub
To display hours, seconds, or minutes instead, you'd simply change the 'Newmsg' variable like so: Newmsg = Hremain & " hours until " & Ddaytxt
Now this is a pretty static example of how to do a countdown where the dates and display text are hardcoded into the widget, but you get the basic idea. Optimally, you'd have the option to change the date and display format on demand--and, ideally, have it stop counting after Dday has passed. But hey, that's why we have RomanDA's Holiday Countdown and Holiday Countdown Pro widgets!
Twinkle, Twinkle!
Island Dog has made some incredible Christmas light widgets (check out his gallery), but Icicle Christmas Lights is my absolute fave. They just look so realistic.
Mesmerized by those blinking lights? You can make them, too. Here we'll see just how to make animated twinkling.
Execution
We need to create and animated PNG. Oh, look! HERE is a tutorial by yours truly that shows you how. Now, for these lights we need to make the colors alternate in each frame. Then, we'll just loop it and watch them twinkle.
Here are the three images I combined to make the animated PNG:
1)
2)
3) ![]()
And here's the combined image:
![]()
There's no scripting necessary; it's all done in the appearance tab. See the image below for the settings.
![]()
Clone 'em, line 'em up, group 'em, and you'll have a whole string. (Now they may not be in sync until you restart DXBuilder, but once you've done that they should alternate in order.)
Jingle Bells!
I actually have three favorite Christmas weather widgets--including Christmas Time Weather by Martin and Christmas Snow Globe Weather by RomanDA-- but if I had to pick one, it would be White Christmas by Richard Mohler. I like it because it's uniquely low-key and I can use it all year round.
I don't know about you but I just see the words "white christmas" and I hear Bing Crosby's crooning. Now, wouldn't it be swell if you could have your favorite jingles and carols play on demand in a tiny widget in the corner of your screen? You can, goshdarnit, and you don't have to load up a media player either.
This one's really a 'did you know' but I thought I'd put it out there anyways.
Concept
Have a seasonal icon in the corner of your screen like, say, this:
![]()
Or this:
![]()
And when you mouse over the object, it begins to play a jingle.
Execution
Create the mouse away and mouse over states. Find the jingle you want. Go to the mouse over state and in the sounds tab load up your song. See image below.
![]()
It plays the entire song, once, as long as your mouse remains over the object, and it stops when you move away. 'Async sound loop' repeats the song as long as your mouse is over the object.
Let it snow! Let it snow! Let it snow!
There's just one word to describe Realistic Snowflakes by GreenReaper: awesome! Watch as the snowflakes drift and float, sway and fall, heavily, lightly, fast, slow--just beautiful!
No, I can't show you how to do the cool effects GreenReaper did with his widget, but I can show you how to make objects fall randomly down your screen. I originally made this script for a birthday surprise widget (where balloons fell down the unsuspecting user's screen), but it works just as well for snowflakes.
Concept
Pick a random spot across the top of your screen, put an object there, then let it move all the way down your screen. Reduce, reuse, and recycle.
Execution
Create and object and name it "snow1" Go to Properties > Summary and set the group name to "snow". Set height and width to 10 x 10 (a good size for a snowflake.)
**SCRIPT UPDATE 12/23/08**
Create another object (you should now have a total of two objects now) and put this script in it:
Dim trigger, objcount
Dim snocount, snowidth, snolimit, snostop, snostart, snodir, snospeed
snocount= 1
objcount= Desktopx.GroupObjects("snow").count
snowidth = system.VScreenWidth - DesktopX.Object("snow1").width
'***Adjust these variables to your preferences***
snolimit = 20 '--How many objects you want
snospeed = 2 '--How fast to go
trigger = 50 '--How far apart are the objects
snodir = "up" '--Which direction (up or down)
'*************************************************
Function Dropsnow '---Move snowflake objects downscreen, duplicate, reset positions--- '---Duplicate snowflake object, and set its starting position---- '---Delete snowflake objects on startup----
'Called when the script is executed
Sub Object_OnScriptEnter
object.KillTimer 1
If snodir = "down" Then
snostart = 0 - DesktopX.object("snow1").height
snostop = system.screenheight
Else
snostart = system.screenheight
snostop = 0 - DesktopX.object("snow1").height
trigger = system.screenheight - trigger
End If
DesktopX.object("snow1").top = snostart
Clearsnow
Dropsnow
End Sub
Object.SetTimer 1, 20
End Function
Sub Object_OnTimer1
objcount= Desktopx.GroupObjects("snow").count
For Each elem In Desktopx.GroupObjects("snow")
If elem.top = trigger Then
If objcount < snolimit Then Duplicate '--if not at limit of total snowflakes, duplicate
End If
Select Case snodir
Case "down"
If elem.top => snostop Then
elem.top= snostart
Randomize Timer '--get random coordinates
snowx = Int(Rnd * snowidth) + 1 '--get random coordinates
elem.left = snowx
Else
elem.top = elem.top + snospeed
End If
Case "up"
If elem.top <= snostop Then
elem.top= snostart
Randomize Timer '--get random coordinates
snowx = Int(Rnd * snowidth) + 1 '--get random coordinates
elem.left = snowx
Else
elem.top = elem.top - snospeed
End If
End Select
Next
End Sub
Function Duplicate
Randomize Timer
snowx = Int(Rnd * snowidth) + 1
snocount = snocount + 1
snoname= "snow" & snocount
Desktopx.Object("snow1").clone snoname, snowx, snostart
End Function
Function Clearsnow
For x = 2 To objcount
Desktopx.Object("snow" & x).delete
Next
End Function
**Notice the portion of the script between the star lines. You can change these variables to adjust the settings of the falling objects, such as speed, spacing, direction, and amount.
There you go. It's a pretty rudimentary script but hopefully you get the basic idea behind it.
Well, that's it! Thanks for reading. Happy Holidays (and happy birthday to me!)
Reply #2 Friday, December 19, 2008 9:23 AM
Trigger = 25
yearcount = ?
objcount = happy_birthday sViz
Function DropJoy on sViz For x = ? years
Thanks for this great post and the effort to do it!
Please turn this Post into a Tutorial for the Win Wikipedia!
Sub Object_OnScriptEnter
Desktopx.Object("sViz").top = system.VScreenTop - 50
object.KillTimer 1
Clearsnow
Dropsnow....................on whoever loves it! Happy Holidays to sViz!!!!!! ![]()
Doc
Reply #3 Friday, December 19, 2008 10:25 AM
Thanks for the great info, but more so....Happy Birthday. HAPPY HOLIDAYS to you and yours!![]()
Reply #4 Friday, December 19, 2008 10:49 AM
Im sure this will help some folks a lot, thanks and Happy B-\Holidays! ![]()
Reply #5 Friday, December 19, 2008 10:49 AM
You mean DesktopX things aren't witchcraft and alchemy? I was pretty sure that chickens had to be killed and candles needed to be burning in order to create these things. And what is this "script" you speak of? I've been afraid to learn this language, for fear I would lose my soul. (OH WAIT! I don't have one of those! Silly me) ![]()
Reply #6 Friday, December 19, 2008 11:06 AM
Who says they aren't?
![]()
That is why I'm buying my school supplies and trundling off to DX school....the really good one's wouldn't have me.
![]()
Reply #7 Friday, December 19, 2008 1:27 PM
Thanks guys and gals! I'll put it up on the wiki soon.
LOL! No magic involved; just a lot of time, practice and patience (lots and lots of patience
)
Shh! Do you wish to be expelled from the Order of DX for exposing our secretive ways? You shall have to slaughter five cows as pennance for this offense!
![]()
Reply #9 Friday, December 19, 2008 2:21 PM
The way I look at it is that I wouldn't want to be a member of a club that had me as a member either!
![]()
Reply #10 Friday, December 19, 2008 2:42 PM
Awesome work on this extended tutorial! ![]()
actually, you can get by with sacrificing some KFC, or at a pinch, a couple of fried eggs on toast
Reply #11 Saturday, December 20, 2008 9:36 AM
I tried the snow script, did everything, and nothing happens, it's just 1 object that's static ![]()
Reply #13 Saturday, December 20, 2008 8:33 PM
The countdown gives a script error line 17, invalid character. ![]()
Reply #17 Saturday, December 20, 2008 11:59 PM
ROFLMAO!!!!!!!
![]()
Reply #18 Sunday, December 21, 2008 12:13 AM
Quoting Tailsgirl,
reply 15
I prefer rubber ones Karen
Sure YOU do, but the kitties who own you would prefer you bring home the real ones. You know how their kitty brains work--rubber toys, meh; feather toys, WOOT!
But it's our State bird! ![]()

Reply #19 Monday, December 22, 2008 6:44 PM
Thanks for the script edit sViz, falling objects works like a charm! ![]()
Move snowflake objects downscreen
sViz, how would I change it to move upscreen?
I'm making aquarium bubbles ![]()
Reply #20 Monday, December 22, 2008 9:19 PM
Sounds cool. I'm away from my main machine now, but a stab in the dark would be to just reverse everything--or better, create more conditionals so that it only requires the change of one variable from "down" to "up" and the rest takes care of itself. I'll probably get around to it tomorrow.
The countdown script is also fixed. The pesky apostrophes didn't translate well when posting, creating the syntax error. Apologies for any undue headaches. And thanks for pointing out the problems, Tailsgirl.
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!











Reply #1 Friday, December 19, 2008 9:21 AM
Thanks for that, very useful, and a Happy Birthday to you buddy!
