Countdown to disaster - Part 6

Date and Flames

Saturday, November 1, 2008 by RomanDA | Discussion: DesktopX Tutorials

Ok all.. lets add a few more little details.

FLAMES:

I made a small PNG (its not great im not a great graphics guy) with 4 states to it that when put into DX and be "animated".

Here is what it looks like when cloned 5 times (and shrunk to death!).

Steps:

  • Create new object called FlameBG
  • I used the 5x5 blank i made in the first part for the background image, set its transparancy to about 5
    for now, it will be 0 when its done.
  • I positioned this box so that it would be big enough to cover the candles so that i could make the flames
    Children of this box, and then i would be able to "move" the box for the mini and large backgrounds.
  • I made a new object called "Flame1" and made its animation state as shown:



  • I Cloned the flames 4 more times.
  • In order to make the flames look a little different, i made one's animation "style" set to "forward" then "backward" then "f + b" then "b + f".
  • I made them all "children" of the FlameBG object, and positioned them over the candles.

Now for some more code:
In order to make the FlameBG move, i had to position it for the Large and the Mini cakes, and write down the top/left position for each background.  Then I modified the code to move this when you clicked the mini/large buttons.
FT = Flame top, FL = Flame left

Code: vbscript
  1. Function SetMode(Mode)
  2.   desktopx.Object("Birthday-CD-Flame-BG").visible = False
  3.     Select Case Mode
  4.         Case "Mini"
  5.       desktopx.object("Birthday-CD-LargeBG").visible = False
  6.         desktopx.object("Birthday-CD-MiniBG").visible = True
  7.         FT = 48 : FL = 193
  8.         Call SetINIValue("Mode","Mini")
  9.         Case "Large"
  10.         desktopx.object("Birthday-CD-MiniBG").visible = False
  11.       desktopx.object("Birthday-CD-LargeBG").visible = True
  12.         FT = 74 : FL = 204
  13.       Call SetINIValue("Mode","Large")
  14.     End Select
  15.   desktopx.Object("Birthday-CD-Flame-BG").top = FT
  16.   desktopx.Object("Birthday-CD-Flame-BG").left = FL
  17.   desktopx.Object("Birthday-CD-Flame-BG").visible = True
  18. End Function

You will see i make the flames visibility= false before i move it, then i swap the backgrounds, then i make it visible again.
This way you dont see it "move".

Again, this is the main reason for using "Functions", I didnt have to modify the code where i Call the Mode, and i can still go in and add even more functionality to the swap at a later time (fades, etc).

As i stated in the previous tutorial we needed to make the day/month work for international users not just USA.  To do this i went looking and found a function that the TRUE DX master VAD_M created called FormatDate.

This is an awesome function because you can pass it a date in m/d/y and it will format it in the locale's format.
Here is the function:

Code: vbscript
  1. '---- FIX DATE FOR ANY LOCATION
  2. Function FormatDate(xdate)
  3.     On Error Resume Next
  4.   Dim ,s1,s2,sx
  5.      If instr(xdate,"/") > 0 Then
  6.       s1 = "/"
  7.      ElseIf instr(xdate,".") > 0 Then
  8.       s1 = "."
  9.      ElseIf instr(xdate,"-") > 0 Then
  10.       s1 = "-"
  11.      End If
  12.      Set objShell = CreateObject("WScript.Shell")
  13.   = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sShortDate")
  14.   s2 = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sDate")
  15.      Set objShell = nothing
  16.   sx = split(xdate,s1)
  17.   If left(LCase( ),1) = "d" Then = sx(1)&s2&sx(0)&s2&sx(2) Else = sx(0)&s2&sx(1)&s2&sx(2)
  18.   FormatDate = FormatDateTime( ,2)
  19.      Set = nothing
  20.      Set s1 = nothing
  21.      Set s2 = nothing
  22.      Set sx = nothing
  23. End Function

Then we have to make a few changes to the GetBDay Function to CALL this new Function.

Code: vbscript
  1. Function GetBDay()
  2.   BdayToday = False
  3.   testDate = FormatDate(BMonth &"/" & BDay &"/" & year(now))
  4.   CheckDate = IsDate(testDate)
  5.   If CheckDate <> True Then
  6.    Msgbox "Date: " & testDate & vbnewline & "is Invalid" & vbnewline & "Please select a new date"
  7.    Call PrefsMenu()
  8.   Else
  9.         s = DateDiff("s", Now, testdate)
  10.         If s > 0 Then
  11.             BDate = cdate(testdate)
  12.         Else
  13.           testDate = FormatDate(BMonth &"/" & BDay &"/" & (year(now)+1))
  14.             BDate = cdate(testdate)
  15.       End If
  16.       d = DateDiff("d", Now, testdate)
  17.       If d= 365 Then        msgbox "HAPPY BIRTHDAY!!"
  18.       desktopx.Object("Birthday-CD-Mini-BDate").text = BDate
  19.   End If
  20. End Function

IE:

testDate = FormatDate(BMonth &"/" & BDay &"/" & year(now))

This seems to have fixed the problem with the d/m/y vs  m/d/y formats.

So now i have had a few people test it and it seems to be working.
It is saving the day/month/mode just fine, and seems to be doing the countdown.

The next hurdle is to make this do "something" special on the actual birthday.
I need input here, what should it do?

Play "Happy Birthday" or some other mp3 file?
Change the image to someone new?
What else?

PLEASE post and let me know what you think it should do.

RomanDA

ZubaZ
Reply #1 Saturday, November 1, 2008 10:22 PM

The next hurdle is to make this do "something" special on the actual birthday.
I need input here, what should it do?

Play "Happy Birthday" or some other mp3 file?
Change the image to someone new?
What else?
Dancing girls.

I think I know one with a pole 

yrag
Reply #2 Saturday, November 1, 2008 10:36 PM

Dancing girls.

I think I know one with a pole

ahhh...I believe that one would be a guy, Zuby..........

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