Learning DX Step-By-Step - #10
Hide & Seek
Thursday, May 31, 2007 by RomanDA | Discussion: DesktopX Tutorials
Step-by-Step Tutorials |
#10 - Hide & Seek |
A series by RomanDA |
Listing of other DX Tutorials:
Click here
Today's Lesson: "Hide & Seek"
This will be the last in this series
of Tutorials. I hope you have enjoyed them, and managed to get something out of
them.
In this lesson we will do some basic DX operations on one object from another.
We will cover the following:
- HIDE/SHOW one object by clicking on another
- SLIDE/HIDE one object by clicking on another
- EXPAND/SHRINK one object by clicking on another
For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.
Lets get started.
STEP 1 - Create the objects
For this tutorial we will be using 3 objects: (right click and SAVE the images to your pc)
Mask | |
Button | |
Target |
- Create 3 objects. (look at the old tutorials for info on how to do this)
- Create an object called Mask
- width: 260
- height: 90
- Group Tutorial10
- Widget Tutorial10
- NOTE: we will later change the transparency to 0, but for now we want to see how the mask makes things work.
- Create an object called Target
- Make its PARENT object MASK
- place it at 0,0 for top/left.
- Group Tutorial10
- Widget Tutorial10
- Create an object called Button
- place it above the TARGET/MASK object (like you see in the table above, just above it)
- Widget Tutorial10
- NO GROUP!!!!
- We will make a VERY simple script on Button to hide/show Target.
STEP 2 - Add a simple HIDE/SHOW Script
Add the following script to Button:
BUTTON Code | |
Function Object_OnLButtonUp(x, y, Dragged) |
Lets look at the above script.
Its VERY simple, we look at the Visibility of Target and see if its True
(is it visible), if so, we HIDE it (False), if its Hidden (False) we Show it (True).
BUTTON Code | |
If desktopx.Object("Target").visible = True Then 'is Target Visible? |
That's all there is to it.
SAVE the code.
Click Button to see how it toggles Target on/off.
The MASK will stay there, but that's ok for now, we will play with that NEXT.
Here is what you will see:
Normal View | CLICKED |
STEP 3 - Sliding Target
Now, lets change things up. Lets make the TARGET SLIDE up into the menu. We do this by making a script that has a few Timers (in order to slow up the sliding).
The script is a modified version of my script I used in another tutorial. The basics are this.
- The
Function Object_OnLButtonUp(x, y, Dragged)
is the button being pressed (well released)
Inside here we look at the TOP position of the TARGET.
If the TARGET's top is = 0 this means its being shown and is at the normal position, so we want to HIDE it (Timer 200).
If not then we want to SHOW it (Timer 100).
We kill the timer just to be sure, then we set the correct timer to start. - In the timers we simply look
to see if the top is at 0 or at -90 (shown / hidden).
All we do to HIDE the TARGET is to move it 5 spaces at a time UP - Because we have the TARGET's parent as a MASK it will move up past the Visible area the mask shows, so it will look like its vanishing.
- In the Timer we keep moving it UP until it reaches -90 (the object it 88 pixels tall), then we kill the timer.
- When we click the button again it sees the TARGET.top position is -90 and it SHOWS it by doing the opposite as it does to SHOW it.
- We move it DOWN 5 pixels at a time till its back to 0, with the mask setup it looks like its sliding from nowhere.
- We are using this
Sub Object_OnScriptEnter
To set the initial TARGET position to 0, just so that it shows the menu on startup. If you wanted to have the menu HIDDEN on startup, you would change the 0 to -90
desktopx.Object("Target").top = 0
End Sub
Here is the script to SLIDE the TARGET UP/DOWN: (this code goes in the
BUTTON)
REPLACE the code from the "HIDE/SHOW" above.
BUTTON Code | |
Sub Object_OnScriptEnter |
This would end up looking like this (when you click the button it goes UP then DOWN):
To make this look a LOT better you
could go in and make the MASK's transparency = 0 so that its basically invisible.
You can use whatever objects you want, you would only have to change the -90 to
the correct height for the object you want to use.
Again, these are just samples for you to work with.
STEP 3 - Shrinking / Expanding
Ok, so we know how to HIDE/SHOW by clicking the button, and we can make it SLIDE UP and DOWN too. Now lets make the TARGET EXPAND / SHRINK.
To do this we will use some of the same functions as above. Only now we want to not MOVE the TOP, we want to change the WIDTH of the TARGET.
The targets "default" size is: 255x88 What we want it to do is shrink down to 30x88 (so that it EXPANDS out from the left to the right).
One of the things we need to do is
change the ADVANCED settings on the TARGET image.
Click on properties, then States then ADVANCED:
This will make it so the 3d EDGE of the TARGET stays the right width, and the insides kind of Expand.
BUTTON Code | |
Sub Object_OnScriptEnter |
This would end up looking like this
(when you click the button it EXPANDS / SHRINKS):
It wont look exactly like this, the edges should stay and the middle should shrink
(I just dumped this into flash, so its not the same).
In the case of the EXPAND/SHRINK, you do NOT need the MASK, so you could delete that object. I left it here only for reference.
CONCLUSION
I hope you took the time to enter the code (not just copy/pasted the entire thing) so you could work thru the tutorial step-by-step and see how things work.
This tutorial is actually 3 in 1. But they are related, so I wanted to make this last Tutorial a good one.
This will be my last tutorial for a while. I hope you have enjoyed this step into DX.
Enjoy, RomanDA AKA: David A. Roman http://romanda.wincustomize.com |
Reply #2 Thursday, May 31, 2007 5:21 PM
RomanDA is going "WTF?" right now.
No. I can't. But I'd love to see who could. Maybe a contest?
Thanks for doing all these David. While there aren't many comments in these threads, I've seen more interesting stuff come out of DX since you started this.
Reply #3 Thursday, May 31, 2007 5:26 PM
For now, I'm just kind of done with them, they take so much time and effort, and really it does seem like no one is noticing them. Its hard to put a lot of effort into things if no one is going to use it.
Reply #4 Thursday, May 31, 2007 5:36 PM
It's sad but there are too many people who look, enjoy but don't put a word to say thanks.
But i don't think i'm alone to find them awesome and your kindness also to share your knowledge with us.
For me it's MASTER RomanDA (Sorry Zu but it's true )
Reply #6 Friday, June 1, 2007 12:31 AM
Reply #8 Friday, June 1, 2007 11:11 AM
Reply #9 Friday, June 1, 2007 12:26 PM
I'm not sure it's the fact that people Don't notice them as much as The scripts can be over whelming to some people. Some people find writing a script very simple while others just can't write or understand the inner working of scripts. Then you have people like me that have a hard time concentrating on something for a long period of time. I can change simple code to what I need but if it is complex code then I can't follow it because I can't remember where I was. Another thing is the fact there really isn't that many people doing DXThemes. Then you take the people that can code but can't make decent graphics and you really narrow down the field. There seems to be a few more doing DXThemes now and using scripts in their themes. A lot of people where turned off of DX by the earlier versions that were unstable Now that DX is pretty stable I think you will see more people doing Themes and Using scripts.
Another thing I have noticed is the fact that people tend to download the simple themes over the more complex themes. Maybe this is one reason you don't see to many using scripts in themes.
Any way I will stop here and just say Thanks again for all your hard work and for sharing with the rest of us.
Reply #11 Friday, June 1, 2007 3:00 PM
This is a lot simpler to grasp than Tombalachi's script.
Reply #12 Friday, June 1, 2007 9:27 PM
Thanks, im glad, sometimes im not sure if im over people's heads or really boring.
Reply #13 Sunday, June 3, 2007 6:39 PM
Reply #14 Tuesday, June 5, 2007 2:26 PM
Thanks a ton!!!!
Reply #15 Wednesday, June 6, 2007 4:57 PM
Im so glad they have helped. Maybe there will be more once 4.0 comes out. Who knows. If i get in on 4.0 early so i can find the new toys.. (Hint for Brad!!)
Reply #19 Sunday, June 19, 2011 3:10 AM
the link above shows 1 though 7
can you please give a link to 8 and 9
and on that link above there is this
Below is a list of the older tutorials I made (these are more advanced then the Step-By-Step ones above.
but I see NO Step-By-Step ones above
thanks
Reply #20 Sunday, June 19, 2011 11:19 AM
Listing of other DX Tutorials: Click here
the link above shows 1 though 7
can you please give a link to 8 and 9
and on that link above there is this
Below is a list of the older tutorials I made (these are more advanced then the Step-By-Step ones above.
but I see NO Step-By-Step ones above
thanks
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 Thursday, May 31, 2007 5:11 PM