Merry DXmas!

Holiday-themed tutorials

Merry DXmas!

 

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) frame 1 2) frame 2 3) frame 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.

 Animation Tab 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)
'*************************************************


'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

 

Function Dropsnow
 Object.SetTimer 1, 20
End Function

 

'---Move snowflake objects downscreen, duplicate, reset positions---
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

 

'---Duplicate snowflake object, and set its starting position----
Function Duplicate
 Randomize Timer
 snowx = Int(Rnd * snowidth) + 1
 snocount = snocount + 1
 snoname= "snow" & snocount
 Desktopx.Object("snow1").clone snoname, snowx, snostart
End Function

 

'---Delete snowflake objects on startup----
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!)

 

 

 

23,975 views 29 replies
Reply #1 Top

Thanks for that, very useful, and a Happy Birthday to you buddy! :) :beer: :beer: :beer:

Reply #2 Top

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!!!!!!  :grin:

Doc

Reply #3 Top

Thanks for the great info, but more so....Happy Birthday.  HAPPY HOLIDAYS to you and yours!:thumbsup:

Reply #4 Top

Im sure this will help some folks a lot, thanks and Happy B-\Holidays! :snowman:

Reply #5 Top

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)  :rofl:

Reply #6 Top

I was pretty sure that chickens had to be killed and candles needed to be burning in order to create these things.

Who says they aren't?  :O ;P

 

That is why I'm buying my school supplies and trundling off to DX school....the really good one's wouldn't have me.  X| XD ;)

Reply #7 Top

Thanks guys and gals! I'll put it up on the wiki soon.

Quoting k10w3, reply 5
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) 

LOL! No magic involved; just a lot of time, practice and patience (lots and lots of patience X| )

 

Who says they aren't?

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! :moo: :X *_*

Reply #8 Top

Quoting sViz, reply 7


LOL! No magic involved; just a lot of time, practice and patience (lots and lots of patience )
 


Ohhhh....it's not magic, it's child birth and parenting!

Reply #9 Top

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!

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!  8| :P

Reply #10 Top

Awesome work on this extended tutorial! :thumbsup:

I was pretty sure that chickens had to be killed and candles needed to be burning in order to create these things.

actually, you can get by with sacrificing some KFC, or at a pinch, a couple of fried eggs on toast

Reply #11 Top

I tried the snow script, did everything, and nothing happens, it's just 1 object that's static :pout:

Reply #12 Top

Merry Chirstmas to you too sViz! Thanks B)

Reply #13 Top

The countdown gives a script error line 17, invalid character. :(

Reply #14 Top

Quoting Tailsgirl, reply 13
The countdown gives a script error line 17, invalid character.


That's what happens when you use KFC instead of live chickens. ;)

+2 Loading…
Reply #16 Top

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!

Reply #17 Top

That is why I'm buying my school supplies and trundling off to DX school....the really good one's wouldn't have me.

ROFLMAO!!!!!!!    :rofl: :rofl: :rofl:

Reply #18 Top

Quoting k10w3, reply 16



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 Top

Thanks for the script edit sViz, falling objects works like a charm! :inlove:

Move snowflake objects downscreen

 

sViz, how would I change it to move upscreen?

I'm making aquarium bubbles :)

Reply #20 Top

sViz, how would I change it to move upscreen? I'm making aquarium bubbles

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.

Reply #21 Top

Thanks sViz, I have to keep reloading the script because it stops working if i try and edit anything :moon:

 

I changed everything that said Top, to Bottom, but I guess that's not what I'm meant to edit hehe

I have NO idea what I'm doing LOL:grin:

Trial and error, mainly error in my case hehe

 

Edit:I just did a test export, whoa, my cpu is being eaten , I need less bubbles, and set to one part of the screen , like left or right, like fishtank pump bubbles, going upwards :)

Reply #22 Top

New script is up. You can now easily change the amount of objects, speed, spacing, and direction.

Reply #23 Top

Awesome sViz, you totally rock! :beer:

 

Dang, no matter what I do, it still falls down sViz :grin:

Reply #24 Top

You mean the objects are going down instead of up? Make sure the variable 'snodir' is set to "up" instead of "down"

+1 Loading…
Reply #25 Top

Yep sViz, I changed all instances of snodir to up, but no go hehe