Dx Scripting Help

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
  1. 'Called when the script is executed
  2. Sub Object_OnScriptEnter
  3. End Sub
  4. 'Called when the script is terminated
  5. Sub Object_OnScriptExit
  6. End Sub
  7. Sub Object_OnScriptEnter
  8.   desktopx.Object("Target6").top = 0
  9. End Sub
  10. Function Object_OnLButtonUp(x, y, Dragged)
  11.   If Dragged = False Then
  12.     If desktopx.Object("Target6").Left = 0 Then
  13.       object.KillTimer 100
  14.       object.SetTimer 200,10
  15.     Else
  16.       object.KillTimer 200
  17.       object.SetTimer 100,10
  18.     End If
  19.   End If
  20. End Function
  21.  
  22. Sub object_ontimer100
  23.   If desktopx.Object("Target6").Left < 0 Then
  24.     desktopx.Object("Target6").Left = desktopx.Object("Target6").Left + 5
  25.   Else
  26.     object.KillTimer 100
  27.   End If
  28. End Sub
  29.  
  30. Sub object_ontimer200
  31.   If desktopx.Object("Target6").Left > - 300 Then
  32.     desktopx.Object("Target6").Left = desktopx.Object("Target6").Left - 5
  33.   Else
  34.     object.KillTimer 200
  35.   End If
  36. End Sub

9,206 views 6 replies
Reply #1 Top

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

Reply #2 Top

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.

Reply #3 Top

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

Reply #4 Top

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

Reply #5 Top

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.

 

+1 Loading…
Reply #6 Top

Wow, you are awesome, will dig into that later :thumbsup: k6 :w00t: