Help Needed With Mask in DesktopX

Tuesday, February 17, 2009 by PoSmedley | Discussion: DesktopX Tutorials

I am trying to follow RomanDA's script for masks.  I want to 'swap out' multiple objects. $ (possibly5..maybe 6..but if I get just 4 I'd be happy)

I tried making multiple widgets..but having to go in and set each and every object...nah. I tried to do it all with the scripting..but..well..it goes all goofy on me.

I am using the 'arrows' (see video below) to 'slide' them in and out. I want to use the top arrow to keep advancing and the bottom arrow to go back to the previous one. I'd like to put them all in one widget so I can have a button to go back to the main bar. The video will explain or show what I mean AND what I am doing wrong, better.

 

 

 

Can anyone help with this? I can't figure hiw to have four or more objects and have them come in and out seperatley. I hope you can understand what I mean.

First Previous Page 1 of 3 Next Last
WebGizmos
Reply #1 Tuesday, February 17, 2009 5:39 AM

I'm as confused as a baby in a topless bar!

bilbo1930
Reply #2 Tuesday, February 17, 2009 5:44 AM

This video is private...I'm not see.

superman
Reply #3 Tuesday, February 17, 2009 5:55 AM

Dear, would you please post the link for script which you are trying to use? I am not able to get any idea from video.

PoSmedley
Reply #4 Tuesday, February 17, 2009 6:37 AM

This video is private...I'm not see.

Sorry. Fixed and made public.

 

Here is a link for the tutorial/script

Let me try to explain...

  1. Click windows button to go to menu
  2. First choice is 'Folders' and you have the two arrows. Forward> for next choice, <back for previous. (In this first instance, '<back' would take you back to the windows button.)
  3. Press forward and what I WANT to happen is 'Folders' slides <back and 'Media' slides forward>
  4. To go to 'next' choice, press the forward> arrow - To go back to 'Folders' press the <back arrow
  5. and so on
  6. You can click on the object (ie, Folders) to call up your folders, etc.
bilbo1930
Reply #5 Tuesday, February 17, 2009 7:47 AM

You can try this: link not available

dxpack.

some object not visible (100% trans...) 

PoSmedley
Reply #6 Tuesday, February 17, 2009 9:54 AM

You can try this:

I found that one this morning. It's what I want..BUT......try adding a third target

'Target3'

This is what I have.

 

 

 

Const oTarget = "Target01"
Const oTarget2 = "Target03"
Const oTarget3 = "Target02"

Function Object_OnLButtonUp(x, y, Dragged)
If Dragged = False Then
If desktopx.Object(oTarget).left = 0 Then
object.KillTimer 100
object.SetTimer 200,17
Else
object.KillTimer 200
object.SetTimer 100,17
End If
End If
End Function

Sub Object_OnScriptEnter
With DesktopX
.Object(oTarget).left = 0
.Object(oTarget2).left = -410
.Object(oTarget3).left = -410
End With
End Sub

Sub object_ontimer100
If desktopx.Object(oTarget).left < 0 Then
desktopx.Object(oTarget).left = desktopx.Object(oTarget).left + 10
desktopx.Object(oTarget2).left = desktopx.Object(oTarget2).left - 10
desktopx.Object(oTarget3).left = desktopx.Object(oTarget3).left - 0
Else
object.KillTimer 100
End If
End Sub

Sub object_ontimer200
If desktopx.Object(oTarget).left > -410 Then
desktopx.Object(oTarget).left = desktopx.Object(oTarget).left - 10
desktopx.Object(oTarget2).left = desktopx.Object(oTarget2).left + 10
desktopx.Object(oTarget3).left = desktopx.Object(oTarget3).left - 0
Else
object.KillTimer 200
End If End Sub

 

Now, targets 'Target' and 'Target2' still slide back and forth if I leave it like this. But, if i change the last paragraph of code to what I think should work (have 'Target2' slide back and 'Target3' slide in while 'Target' stays out of view) nothing happens at all.

Code I tried in last paragraph..

 

Sub object_ontimer200
If desktopx.Object(oTarget).left > -410 Then
desktopx.Object(oTarget).left = desktopx.Object(oTarget).left - 0
desktopx.Object(oTarget2).left = desktopx.Object(oTarget2).left - 10
desktopx.Object(oTarget3).left = desktopx.Object(oTarget3).left + 10
Else
object.KillTimer 200
End If End Sub

I tried changing other bits, but nothing happens. Everything sits still.

 

I want to keep clicking on the >forward' arrow to 'slide' through 4 objects...not just back and forth between two. The bottom arrow would do the same thing in reverse.

PoSmedley
Reply #7 Tuesday, February 17, 2009 8:18 PM

Padded Room

RomanDA
Reply #8 Tuesday, February 17, 2009 9:19 PM

Po... if you can send me this ill look at it

PoSmedley
Reply #9 Wednesday, February 18, 2009 8:42 AM

Po... if you can send me this ill look at it

It's in the mail. Thank you!

RomanDA
Reply #10 Wednesday, February 18, 2009 9:56 AM

Its working now, check email!

PoSmedley
Reply #11 Wednesday, February 18, 2009 8:09 PM

Its working now, check email!

It's perfect! And I can add objects to it. EXACTLY what I wanted. Thank you. I'm sorry you had to re-write it. I was sure I was just missing something with my original script and was hoping I was at least close.

 

Thanks again!

RomanDA
Reply #12 Thursday, February 19, 2009 10:29 AM

No problems bud.. it was close, i just made it easier to add more items to it.  Now you can add as many sliding objects as you want, without any real code changes.

All you would have to edit is:

 

Const oCount = 3 ---- CHANGE THIS TO THE MAX NO OF ITEMS
Dim oTarget(3) ----- CHANGE THE 3 to BE THE MAX NO LIKE ABOVE
oTarget(1) = "Target01"
oTarget(2) = "Target02"
oTarget(3) = "Target03"

oTarget(4) = "Target04" --- ADD MORE HERE

And you could name the actual objectes anything you want.

 

The graphics are wonderful, just need to be about 1/2 the size.. LOL

If you do change the size, just change these:

Const EndPos = -410
Const StartPos = 0

Espically the -410 to the right value for the smaller objects.  You could also allow a "scale factor" in the setup like

SCALE: Full Size,80%,75%,etc


Then you could store that in a Var and just do this:

ScaleFactor = .75 (or 1.0, or 2.0 or .50)

 

EndPos = -410 * ScaleFactor

This would allow the script to move things the correct distance based on the scale factor.

 

Just an idea.

 

RomanDA
Reply #13 Thursday, February 19, 2009 10:54 AM

Ok.. PO.. try this..

1. change the name of MASX to Mask -- case is important here

Replace the code with this:

Code: vbscript
  1. 'Assign a constant for each object
  2. 'Reason: It's easier to change Object Names in one spot than an entire script
  3. 'Eg. If you rename an object than just change the name in the quotes
  4. ScaleFactor = 1.0
  5. oCount = 3
  6. EndPos = -410
  7. StartPos = 0
  8. oItem = 1
  9. nItem = 2
  10. Dim oTarget(3)
  11. oTarget(1) = "Target01"
  12. oTarget(2) = "Target02"
  13. oTarget(3) = "Target03"
  14. Sub Object_OnScriptEnter
  15.     Call ScaleMe()
  16.     oItem = 2 'This is the DEFAULT item it shows.. 1,2, or 3 in this case
  17.     ' You could make this read the value from a persiststorage
  18.     'you would have to add a write for it at the end of each TIMER section
  19.    
  20.     'We then set ALL items left to EndPos
  21.   For x = 1 To oCount
  22.       DesktopX.Object(oTarget(x)).left = EndPos
  23.   Next
  24.   'Then we set the CURRENT item's left to 0
  25.   DesktopX.Object(oTarget(oitem)).left = 0
  26. End Sub
  27. ' The reson for the below function is so we can keep ALL
  28. ' the code in 1 object, the buttons have "EMPTY" scripts now
  29. ' it Checkes the NAME of the Button - this has to match EXaCtLy - Case Sensitive
  30. Function Object_OnLButtonUpEx(obj,x,y,dragged)
  31.     If Not dragged Then
  32.         Select Case obj.name
  33.     Case "BTN_Next"
  34.         object.SetTimer 100,17
  35.     Case "BTN_Prev"
  36.         object.SetTimer 200,17
  37.         End Select
  38.   End If
  39. End Function
  40. 'This timer is for the NEXT function
  41. Sub object_ontimer100
  42.     nItem = oItem + 1
  43.     If nItem > oCount Then nItem = 1
  44.     CurItem = oTarget(oItem) ' Current items name
  45.      NextItem = oTarget(nItem) ' NEXT items name
  46.   If desktopx.Object(CurItem).left > EndPos Then
  47.     desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - 10
  48.     desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + 10
  49.   Else
  50.         oItem = oItem + 1 ' We ADD 1 to the Current item AFTER we are done moving things
  51.         If oItem > oCount Then oItem = 1 ' same check as above to see if the item+1> total items
  52.     object.KillTimer 100
  53.   End If
  54. End Sub
  55. 'We do the same thing for the PREVIOUS button except
  56. 'we subtract 1 from the current item
  57. 'if its less then 0 we go to the END of the total count
  58. 'in this case that means item 3
  59. Sub object_ontimer200
  60.     nItem = oItem - 1
  61.     If nItem < 1 Then nItem = oCount
  62.     CurItem = oTarget(oItem)
  63.      NextItem = oTarget(nItem)
  64.   If desktopx.Object(CurItem).left > EndPos Then
  65.     desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
  66.     desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
  67.   Else
  68.         oItem = oItem - 1
  69.         If oItem < 1 Then oItem = oCount
  70.     object.KillTimer 200
  71.   End If
  72. End Sub
  73. Function ScaleMe()
  74.     desktopx.Object("MENU1").resize (609 * ScaleFactor),(180 * ScaleFactor)
  75.     desktopx.Object("title1").resize (70 * ScaleFactor),(157 * ScaleFactor)
  76.     desktopx.Object("title1").top = 5 * ScaleFactor
  77.     desktopx.Object("title1").left = 35 * ScaleFactor
  78.     desktopx.Object("Mask").resize (410 * ScaleFactor),(180 * ScaleFactor)
  79.     desktopx.Object("Mask").top = -5 * ScaleFactor
  80.     desktopx.Object("Mask").left = 110 * ScaleFactor
  81.    
  82.     desktopx.Object("BTN_Next").resize (40 * ScaleFactor),(53 * ScaleFactor)
  83.     desktopx.Object("BTN_Next").top = 16 * ScaleFactor
  84.     desktopx.Object("BTN_Next").left = 515 * ScaleFactor
  85.     desktopx.Object("BTN_Prev").resize (40 * ScaleFactor),(53 * ScaleFactor)
  86.     desktopx.Object("BTN_Prev").top = 107 * ScaleFactor
  87.     desktopx.Object("BTN_Prev").left = 515 * ScaleFactor
  88.    
  89.     For x = 1 To oCount
  90.         desktopx.Object(oTarget(x)).resize (400 * ScaleFactor),(180 * ScaleFactor)
  91.     Next
  92.     EndPos = (-410 * ScaleFactor)
  93. End Function

 

The ScaleMe() funtion at the bottom controls what gets resized, and where it gets moved to.
the 1.0 scale size is "hard-coded" in so that it doesnt keep sizing it every time it loads and making it smaller or larger.. LOL

I would make sure you save things first then try it and see if you like it.

Change the

ScaleFactor = 1.0

to

ScaleFactor =0.5

to see the diff.

ZubaZ
Reply #14 Thursday, February 19, 2009 12:21 PM

That's sweet

RomanDA
Reply #15 Thursday, February 19, 2009 1:03 PM

That's sweet

 

I try

sViz
Reply #16 Thursday, February 19, 2009 2:44 PM

Cool!

RomanDA
Reply #17 Thursday, February 19, 2009 6:14 PM

UPDATED --- I ADDED A FADE in/out for the objects that are sliding, and a fade in on the slider that is the default

I have redone the code here:

Code: vbscript
  1. 'Assign a constant for each object
  2. 'Reason: It's easier to change Object Names in one spot than an entire script
  3. 'Eg. If you rename an object than just change the name in the quotes
  4. Dim ObjName(10),ObjLeft(10),ObjTop(10),ObjHeight(10),ObjWidth(10)
  5. Dim ObjMove(10)
  6. FadePercent = 0
  7. ScaleFactor = 0.7
  8. oCount = 0
  9. EndPos = -410
  10. MasterEndPos = -410
  11. StartPos = 0
  12. oItem = 1
  13. nItem = 2
  14. ObjCnt = 0
  15. Sub Object_OnScriptEnter
  16. '--- Repeat this for each object
  17. '--- the ObjMove Is used To tell the Function to Move the object or not.
  18. '--- the first objects NEED to be the ones that are "sliding"
  19.     FadePercent = 100 / (abs(-410) / 10)
  20.    
  21.     ObjCnt = ObjCnt + 1     : ObjName(ObjCnt) = "Target01"
  22.     ObjTop(ObjCnt) = 0      : ObjLeft(ObjCnt) = 0
  23.     ObjWidth(ObjCnt) = 400  : ObjHeight(ObjCnt) = 180
  24.     ObjMove(ObjCnt) = False
  25.     ObjCnt = ObjCnt + 1     : ObjName(ObjCnt) = "Target02"
  26.     ObjTop(ObjCnt) = 0      : ObjLeft(ObjCnt) = 0
  27.     ObjWidth(ObjCnt) = 400  : ObjHeight(ObjCnt) = 180
  28.     ObjMove(ObjCnt) = False
  29.     ObjCnt = ObjCnt + 1     : ObjName(ObjCnt) = "Target03"
  30.     ObjTop(ObjCnt) = 0      : ObjLeft(ObjCnt) = 0
  31.     ObjWidth(ObjCnt) = 400  : ObjHeight(ObjCnt) = 180
  32.     ObjMove(ObjCnt) = False
  33.     oCount = ObjCnt
  34.     '--- Make sure you make the "count" the same as the # of Sliding Objects.
  35.     ObjCnt = ObjCnt + 1     : ObjName(ObjCnt) = "MENU1"
  36.     ObjTop(ObjCnt) = 0      : ObjLeft(ObjCnt) = 0
  37.     ObjWidth(ObjCnt) = 609  : ObjHeight(ObjCnt) = 180
  38.     ObjMove(ObjCnt) = False
  39.     ObjCnt = ObjCnt + 1    : ObjName(ObjCnt) = "title1"
  40.     ObjTop(ObjCnt) = 5     : ObjLeft(ObjCnt) = 35
  41.     ObjWidth(ObjCnt) = 70  : ObjHeight(ObjCnt) = 157
  42.     ObjMove(ObjCnt) = True
  43.     ObjCnt = ObjCnt + 1    : ObjName(ObjCnt) = "Mask"
  44.     ObjTop(ObjCnt) = -5    : ObjLeft(ObjCnt) = 110
  45.     ObjWidth(ObjCnt) = 410 : ObjHeight(ObjCnt) = 180
  46.     ObjMove(ObjCnt) = True
  47.     ObjCnt = ObjCnt + 1    : ObjName(ObjCnt) = "BTN_Next"
  48.     ObjTop(ObjCnt) = 16    : ObjLeft(ObjCnt) = 515
  49.     ObjWidth(ObjCnt) = 40  : ObjHeight(ObjCnt) = 53
  50.     ObjMove(ObjCnt) = True
  51.     ObjCnt = ObjCnt + 1    : ObjName(ObjCnt) = "BTN_Prev"
  52.     ObjTop(ObjCnt) = 100   : ObjLeft(ObjCnt) = 515
  53.     ObjWidth(ObjCnt) = 40  : ObjHeight(ObjCnt) = 53
  54.     ObjMove(ObjCnt) = True
  55.     Call ScaleMe()
  56.     oItem = 2 'This is the DEFAULT item it shows.. 1,2, or 3 in this case
  57.     ' You could make this read the value from a persiststorage
  58.     'you would have to add a write for it at the end of each TIMER section
  59.    
  60.    
  61.     'We then set ALL items left to EndPos
  62.   For x = 1 To oCount
  63.       DesktopX.Object(ObjName(x)).left = EndPos
  64.       DesktopX.Object(ObjName(x)).opacity = 0
  65.   Next
  66.   'Then we set the CURRENT item's left to 0
  67.   DesktopX.Object(ObjName(oitem)).left = 0
  68.  
  69.   For x = 0 To 100
  70.       DesktopX.Object(ObjName(oitem)).opacity = x
  71.       object.Sleep 5
  72.   Next
  73.  
  74.  
  75. End Sub
  76. ' The reson for the below function is so we can keep ALL
  77. ' the code in 1 object, the buttons have "EMPTY" scripts now
  78. ' it Checkes the NAME of the Button - this has to match EXaCtLy - Case Sensitive
  79. Function Object_OnLButtonUpEx(obj,x,y,dragged)
  80.     If Not dragged Then
  81.         Select Case obj.name
  82.     Case "BTN_Next"
  83.         object.SetTimer 100,17
  84.     Case "BTN_Prev"
  85.         object.SetTimer 200,17
  86.         End Select
  87.   End If
  88. End Function
  89. 'This timer is for the NEXT function
  90. Sub object_ontimer100
  91.      nItem = oItem + 1
  92.     If nItem > oCount Then nItem = 1
  93.     CurItem = ObjName(oItem) ' Current items name
  94.      NextItem = ObjName(nItem) ' NEXT items name
  95.   If desktopx.Object(CurItem).left > EndPos Then
  96.     desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
  97.         DesktopX.Object(CurItem).opacity = DesktopX.Object(CurItem).opacity - FadePercent
  98.     desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
  99.         DesktopX.Object(NextItem).opacity = DesktopX.Object(NextItem).opacity + FadePercent
  100.   Else
  101.         oItem = oItem + 1 ' We ADD 1 to the Current item AFTER we are done moving things
  102.         If oItem > oCount Then oItem = 1 ' same check as above to see if the item+1> total items
  103.     object.KillTimer 100
  104.   End If
  105. End Sub
  106. 'We do the same thing for the PREVIOUS button except
  107. 'we subtract 1 from the current item
  108. 'if its less then 0 we go to the END of the total count
  109. 'in this case that means item 3
  110. Sub object_ontimer200
  111.     nItem = oItem - 1
  112.     If nItem < 1 Then nItem = oCount
  113.     CurItem = ObjName(oItem)
  114.      NextItem = ObjName(nItem)
  115.   If desktopx.Object(CurItem).left > EndPos Then
  116.     desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
  117.         DesktopX.Object(CurItem).opacity = DesktopX.Object(CurItem).opacity - FadePercent
  118.     desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
  119.         DesktopX.Object(NextItem).opacity = DesktopX.Object(NextItem).opacity + FadePercent
  120.   Else
  121.         oItem = oItem - 1
  122.         If oItem < 1 Then oItem = oCount
  123.     object.KillTimer 200
  124.   End If
  125. End Sub
  126. Function ScaleMe()
  127.     For x = 1 To ObjCnt
  128.         desktopx.Object(ObjName(x)).resize (ObjWidth(x) * ScaleFactor),(ObjHeight(x) * ScaleFactor)
  129.         If ObjMove(x) = True Then
  130.             desktopx.Object(ObjName(x)).top = ObjTop(x) * ScaleFactor
  131.             desktopx.Object(ObjName(x)).left = ObjLeft(x) * ScaleFactor
  132.         End If
  133.     Next
  134.     EndPos = (MasterEndPos * ScaleFactor)
  135. End Function

if all your sliding objects are named using the same Item01, Item02, Item03, etc you could use this:

Code: vbscript
  1. '-- 3 is our max item count
  2.  for x = 1 to 3
  3.    t = x
  4.    if x < 10 then  t = "0" & x
  5.     ObjCnt = ObjCnt + 1     : ObjName(ObjCnt) = "Target" & t
  6.     ObjTop(ObjCnt) = 0      : ObjLeft(ObjCnt) = 0
  7.     ObjWidth(ObjCnt) = 400  : ObjHeight(ObjCnt) = 180
  8.     ObjMove(ObjCnt) = False
  9.   next

the little if x <10 is because the objects are named Target01,02,03,10,11,12, etc.  This would take you up to 99 objects.

This is a cool little thing your making Po. 

Just edited this to add the fade in/out i thought it added a lot to the look.

Enjoy.

ZubaZ
Reply #18 Thursday, February 19, 2009 7:32 PM

Having fun David?

I have to say that I really enjoy collaboratins on WC.  Over and over again I see a greater result than what we could do alone.

PuterDudeJim
Reply #19 Thursday, February 19, 2009 7:43 PM

Amen Brother!  This will be awesome, look forward to it, Po! 

bilbo1930
Reply #20 Thursday, February 19, 2009 11:29 PM

Wohoho!!

 

 

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