RomanDA RomanDA

DesktopX Step-By-Step Tutorials #12

DesktopX Step-By-Step Tutorials #12

Stepping Thru States

Step-by-Step Tutorials

#12 - Stepping Thru States

A series by RomanDA

Listing of other DX Tutorials: Click here

Today's Lesson: "Stepping Thru States" is a very simple way to setup multiple states with a button to change between them.

In this lesson we will cover how to create a simple object, then add multiple states to it, and add a simple button to "step" thru the states.

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

See previous tutorials for how to load DX & create a new object.

Lets get started.

 
STEP 1 - Create the first object "state"
With DX loaded and running, add a new object, goto the "STATES" tab and here we will assign the object a new image and then rename the state to "1"

Browse to the 1st background image you want to use, and select it.
Then use the steps below to rename the state to 1.

RIGHT-Click on the
"Mouse Away" in the States window. 
Click "Rename" and name the state "1".

We will be adding more states in the next step, and each one will be another # .  IE: 2, 3, 4, 5.
 
STEP 2 - Create More States 
Add a new STATE naming it "2" and assigning it to the next background image.

You would continue this for ALL the states you want to add.

In our case we will make the TOTAL 8 states.

Repeat - till you have all 8 states added.

"OK" it all when its done.
 
 
STEP 3 - Adding the code to step thru the states.

Edit the above object and click on "NEW  SCRIPT". We will be adding the following script.

Code: vbscript
  1. <span style="font-size: 13px; font-family: Tahoma;">Dim MaxStates, CurrentState
  2. 'Called when the script is executed
  3. Sub Object_OnScriptEnter
  4. MaxStates = 2 '-- Set this to the max # of states
  5. '-- Pull Current State from object
  6. CurrentState = Object.PersistStorage("CurrentState")
  7. '-- check CurrentState to see if it had any value
  8. '-- if not set it to 1
  9. If len(CurrentState) = 0 Then
  10. CurrentState = 1
  11. Widget.AddPreference("CurrentState")
  12. Widget.Preference("CurrentState").defaultvalue = 1
  13. End If
  14. Call SetState() '-- See Function Below
  15. End Sub
  16. Function SetState()
  17. object.state = CurrentState
  18. End Function
  19. Sub Object_OnLButtonDown(x, y)
  20. CurrentState = CurrentState + 1
  21. If CurrentState &gt; MaxStates Then CurrentState = 1
  22. Call SetState()
  23. Widget.Preference("CurrentState").value = CurrentState
  24. End Sub
  25. 'Called when the script is terminated
  26. Sub Object_OnScriptExit
  27. End Sub
  28. </span>

 

You could also add multiple "state" changes to other objects as well (things like Clock hands, or color changes to text objects, etc.
CONCLUSION
There is a lot more you can do with this, but these are the basic steps to setting up the Stepping Object State Changer.

This works great for clocks, and lots of other items where you want to have multiple looks/colors/layouts.

Enjoy,RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com
91,203 views 29 replies
Reply #26 Top

hehehe well you deserve some more Karma David, your Tutorials are a lifesaver, and an inspiration:thumbsup:

Reply #27 Top

Awesome David!!! It works great!! People get ready for Chameleon DX!!!!

Chameleon DX is in moderation. It is a DX theme with 4 different styles. Just a first effort. A Bigger, better theme waits in my brain...lol.

Reply #28 Top

Wow, Thanks for all the great tuts.  I just started learning how to skin dx and these have helped out ALOT.  You planning one for adding the weather info??

Reply #29 Top

You planning one for adding the weather info??

Not at this time..

+2 Loading…