Dx Scripting Help

Wednesday, February 25, 2009 by DigitalT | Discussion: DesktopX Tutorials

I am very new to dx and scripting, so bare with me.  I have a button that when pushed a tray slides out (called target6).  On target6 there is another button that when pushed will open another tray called target9.  Now when i push the original button that opens and closes target6, I would like it to not only close target6 but also target9.  I don't want the main button to open target9 just close it.  Here is just the script attached to the main button.  Works perfectly.  I have tried adding in just the closing portion of the script for target9 and it works, but it only works for target9 and not target6. Help Please.

 

[code]

'Called when the script is executed
Sub Object_OnScriptEnter

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

Sub Object_OnScriptEnter
  desktopx.Object("Target6").top = 0
End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    If desktopx.Object("Target6").Left = 0 Then
      object.KillTimer 100
      object.SetTimer 200,10
    Else
      object.KillTimer 200
      object.SetTimer 100,10
    End If
  End If
End Function
 
Sub object_ontimer100
  If desktopx.Object("Target6").Left < 0 Then
    desktopx.Object("Target6").Left = desktopx.Object("Target6").Left + 5
  Else
    object.KillTimer 100
  End If
End Sub
 
Sub object_ontimer200
  If desktopx.Object("Target6").Left > - 300 Then
    desktopx.Object("Target6").Left = desktopx.Object("Target6").Left - 5
  Else
    object.KillTimer 200
  End If
End Sub

[/code]

RomanDA
Reply #1 Wednesday, February 25, 2009 8:59 PM

in short (since i have no time to code)..

You need several vars.

Code: vbscript
  1. Dim DrawerOpen(10)  --- where 10 is the max number of drawers
  2. MaxDrawers = 10
  3. For x =1 to MaxDrawers
  4.   DrawerOpen(x) = False
  5. Next x

'-- That sets all the drawers to "closed" in the vars

'now in the button that opens the 1st drawer :
' as i have pointed out in multiple other posts (see THIS ONE) i would suggest 1 MASTER object and ALL the other objects having "empty" scripts in them, so that all the code resides in 1 location.  This allows you to easily keep track of things.

So lets say you named the button that opens the first drawer BTN1 & the btn that loads the 2nd slider BTN2 the code would look like:  -- keep in mind CaSe is important here

Code: vbscript
  1. Function Object_OnLButtonUpEx(obj,x,y,dragged)
  2.     If Not dragged Then
  3.         Select Case obj.name
  4.     Case "BTN1"
  5.         '-- ok here we have to make some assumtions - 1 that the drawers are named Drawer1/2/3 etc.
  6.        '-- we will toggle the open/close based on DrawerOpen(1) = True/False 
  7.     if DrawerOpen(1)= False then
  8.       'do whatever you want to open the drawer1 - the code above seems ok
  9.      ' at the END of that add:
  10.      DrawerOpen(1)= True
  11.     else
  12.       'Here is  the check to see if the 2nd drawer opens
  13.       if DrawerOpen(2)= True then ' close the 2nd drawer
  14.         'do whatever you want to close the 2nd drawer first
  15.         DrawerOpen(2)= False 'used to store the fact drawer 2 is closed now
  16.       end if
  17.          'then do whatever it takes to close drawer1
  18.      DrawerOpen(1) = False
  19.     end if
  20.     Case "BTN2"
  21.      'Add similar code here to open/close drawer2       
  22.     End Select
  23.   End If
  24. End Function

Ok i know its not 100% but it should put you on the right track.

1. always keep the code in 1 master object

2. use VARS to store open/closed states, etc.

3. i like to use DIM var so that you dont need things like Drawer1, Drawer2, drawer3, etc.. its all a DIM.. ie: Drawer(1), (2), (3) and its easy to traverse this list.

4. look at what others have done (Zu calls this STEALING but if you dont take their code, just the ideas, or if you ask for the code, its not Stealing) and see how others have done what you are trying to do

5. ok this sounds lame, but i wonder how many people do this.. TRY GOOGLE... ie: DesktopX Slide or DesktopX Buttons, etc.

Good luck

DigitalT
Reply #2 Wednesday, February 25, 2009 9:44 PM

Thanks for the reply will take all this into consideration.  Hopefully I can come up with a working script.  Will let ya know, thanks again.

RomanDA
Reply #3 Wednesday, February 25, 2009 9:48 PM

If not.. i will have some time over the weekend to look at things.. you could email me the dxpack.

DigitalT
Reply #4 Thursday, February 26, 2009 8:49 AM

I will send it your way.  I looked over what you wrote and tried it out myself, but only came up with errors.  Guess there is still a lot that I don't understand.  Thanks

RomanDA
Reply #5 Thursday, February 26, 2009 9:01 PM

Ok.. before you send things look over the demo i uploaded here

 

It should show you how to control some things, if you want me to work on you project later, let me know.

 

DigitalT
Reply #6 Thursday, February 26, 2009 10:12 PM

Wow, you are awesome, will dig into that later

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