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.
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.
Reply #4 Tuesday, February 17, 2009 6:37 AM
Sorry. Fixed and made public.
Here is a link for the tutorial/script
Let me try to explain...
- Click windows button to go to menu
- 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.)
- Press forward and what I WANT to happen is 'Folders' slides <back and 'Media' slides forward>
- To go to 'next' choice, press the forward> arrow - To go back to 'Folders' press the <back arrow
- and so on
- You can click on the object (ie, Folders) to call up your folders, etc.
Reply #5 Tuesday, February 17, 2009 7:47 AM
Reply #6 Tuesday, February 17, 2009 9:54 AM
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.
Reply #9 Wednesday, February 18, 2009 8:42 AM
It's in the mail. Thank you! ![]()
Reply #11 Wednesday, February 18, 2009 8:09 PM
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!
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.
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:
- 'Assign a constant for each object
- 'Reason: It's easier to change Object Names in one spot than an entire script
- 'Eg. If you rename an object than just change the name in the quotes
- ScaleFactor = 1.0
- oCount = 3
- EndPos = -410
- StartPos = 0
- oItem = 1
- nItem = 2
- Dim oTarget(3)
- oTarget(1) = "Target01"
- oTarget(2) = "Target02"
- oTarget(3) = "Target03"
- Sub Object_OnScriptEnter
- Call ScaleMe()
- oItem = 2 'This is the DEFAULT item it shows.. 1,2, or 3 in this case
- ' You could make this read the value from a persiststorage
- 'you would have to add a write for it at the end of each TIMER section
- 'We then set ALL items left to EndPos
- For x = 1 To oCount
- DesktopX.Object(oTarget(x)).left = EndPos
- Next
- 'Then we set the CURRENT item's left to 0
- DesktopX.Object(oTarget(oitem)).left = 0
- End Sub
- ' The reson for the below function is so we can keep ALL
- ' the code in 1 object, the buttons have "EMPTY" scripts now
- ' it Checkes the NAME of the Button - this has to match EXaCtLy - Case Sensitive
- Function Object_OnLButtonUpEx(obj,x,y,dragged)
- If Not dragged Then
- Select Case obj.name
- Case "BTN_Next"
- object.SetTimer 100,17
- Case "BTN_Prev"
- object.SetTimer 200,17
- End Select
- End If
- End Function
- 'This timer is for the NEXT function
- Sub object_ontimer100
- nItem = oItem + 1
- If nItem > oCount Then nItem = 1
- CurItem = oTarget(oItem) ' Current items name
- NextItem = oTarget(nItem) ' NEXT items name
- If desktopx.Object(CurItem).left > EndPos Then
- desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - 10
- desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + 10
- Else
- oItem = oItem + 1 ' We ADD 1 to the Current item AFTER we are done moving things
- If oItem > oCount Then oItem = 1 ' same check as above to see if the item+1> total items
- object.KillTimer 100
- End If
- End Sub
- 'We do the same thing for the PREVIOUS button except
- 'we subtract 1 from the current item
- 'if its less then 0 we go to the END of the total count
- 'in this case that means item 3
- Sub object_ontimer200
- nItem = oItem - 1
- If nItem < 1 Then nItem = oCount
- CurItem = oTarget(oItem)
- NextItem = oTarget(nItem)
- If desktopx.Object(CurItem).left > EndPos Then
- desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
- desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
- Else
- oItem = oItem - 1
- If oItem < 1 Then oItem = oCount
- object.KillTimer 200
- End If
- End Sub
- Function ScaleMe()
- desktopx.Object("MENU1").resize (609 * ScaleFactor),(180 * ScaleFactor)
- desktopx.Object("title1").resize (70 * ScaleFactor),(157 * ScaleFactor)
- desktopx.Object("title1").top = 5 * ScaleFactor
- desktopx.Object("title1").left = 35 * ScaleFactor
- desktopx.Object("Mask").resize (410 * ScaleFactor),(180 * ScaleFactor)
- desktopx.Object("Mask").top = -5 * ScaleFactor
- desktopx.Object("Mask").left = 110 * ScaleFactor
- desktopx.Object("BTN_Next").resize (40 * ScaleFactor),(53 * ScaleFactor)
- desktopx.Object("BTN_Next").top = 16 * ScaleFactor
- desktopx.Object("BTN_Next").left = 515 * ScaleFactor
- desktopx.Object("BTN_Prev").resize (40 * ScaleFactor),(53 * ScaleFactor)
- desktopx.Object("BTN_Prev").top = 107 * ScaleFactor
- desktopx.Object("BTN_Prev").left = 515 * ScaleFactor
- For x = 1 To oCount
- desktopx.Object(oTarget(x)).resize (400 * ScaleFactor),(180 * ScaleFactor)
- Next
- EndPos = (-410 * ScaleFactor)
- 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.
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:
- 'Assign a constant for each object
- 'Reason: It's easier to change Object Names in one spot than an entire script
- 'Eg. If you rename an object than just change the name in the quotes
- Dim ObjName(10),ObjLeft(10),ObjTop(10),ObjHeight(10),ObjWidth(10)
- Dim ObjMove(10)
- FadePercent = 0
- ScaleFactor = 0.7
- oCount = 0
- EndPos = -410
- MasterEndPos = -410
- StartPos = 0
- oItem = 1
- nItem = 2
- ObjCnt = 0
- Sub Object_OnScriptEnter
- '--- Repeat this for each object
- '--- the ObjMove Is used To tell the Function to Move the object or not.
- '--- the first objects NEED to be the ones that are "sliding"
- FadePercent = 100 / (abs(-410) / 10)
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "Target01"
- ObjTop(ObjCnt) = 0 : ObjLeft(ObjCnt) = 0
- ObjWidth(ObjCnt) = 400 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = False
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "Target02"
- ObjTop(ObjCnt) = 0 : ObjLeft(ObjCnt) = 0
- ObjWidth(ObjCnt) = 400 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = False
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "Target03"
- ObjTop(ObjCnt) = 0 : ObjLeft(ObjCnt) = 0
- ObjWidth(ObjCnt) = 400 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = False
- oCount = ObjCnt
- '--- Make sure you make the "count" the same as the # of Sliding Objects.
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "MENU1"
- ObjTop(ObjCnt) = 0 : ObjLeft(ObjCnt) = 0
- ObjWidth(ObjCnt) = 609 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = False
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "title1"
- ObjTop(ObjCnt) = 5 : ObjLeft(ObjCnt) = 35
- ObjWidth(ObjCnt) = 70 : ObjHeight(ObjCnt) = 157
- ObjMove(ObjCnt) = True
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "Mask"
- ObjTop(ObjCnt) = -5 : ObjLeft(ObjCnt) = 110
- ObjWidth(ObjCnt) = 410 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = True
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "BTN_Next"
- ObjTop(ObjCnt) = 16 : ObjLeft(ObjCnt) = 515
- ObjWidth(ObjCnt) = 40 : ObjHeight(ObjCnt) = 53
- ObjMove(ObjCnt) = True
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "BTN_Prev"
- ObjTop(ObjCnt) = 100 : ObjLeft(ObjCnt) = 515
- ObjWidth(ObjCnt) = 40 : ObjHeight(ObjCnt) = 53
- ObjMove(ObjCnt) = True
- Call ScaleMe()
- oItem = 2 'This is the DEFAULT item it shows.. 1,2, or 3 in this case
- ' You could make this read the value from a persiststorage
- 'you would have to add a write for it at the end of each TIMER section
- 'We then set ALL items left to EndPos
- For x = 1 To oCount
- DesktopX.Object(ObjName(x)).left = EndPos
- DesktopX.Object(ObjName(x)).opacity = 0
- Next
- 'Then we set the CURRENT item's left to 0
- DesktopX.Object(ObjName(oitem)).left = 0
- For x = 0 To 100
- DesktopX.Object(ObjName(oitem)).opacity = x
- object.Sleep 5
- Next
- End Sub
- ' The reson for the below function is so we can keep ALL
- ' the code in 1 object, the buttons have "EMPTY" scripts now
- ' it Checkes the NAME of the Button - this has to match EXaCtLy - Case Sensitive
- Function Object_OnLButtonUpEx(obj,x,y,dragged)
- If Not dragged Then
- Select Case obj.name
- Case "BTN_Next"
- object.SetTimer 100,17
- Case "BTN_Prev"
- object.SetTimer 200,17
- End Select
- End If
- End Function
- 'This timer is for the NEXT function
- Sub object_ontimer100
- nItem = oItem + 1
- If nItem > oCount Then nItem = 1
- CurItem = ObjName(oItem) ' Current items name
- NextItem = ObjName(nItem) ' NEXT items name
- If desktopx.Object(CurItem).left > EndPos Then
- desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
- DesktopX.Object(CurItem).opacity = DesktopX.Object(CurItem).opacity - FadePercent
- desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
- DesktopX.Object(NextItem).opacity = DesktopX.Object(NextItem).opacity + FadePercent
- Else
- oItem = oItem + 1 ' We ADD 1 to the Current item AFTER we are done moving things
- If oItem > oCount Then oItem = 1 ' same check as above to see if the item+1> total items
- object.KillTimer 100
- End If
- End Sub
- 'We do the same thing for the PREVIOUS button except
- 'we subtract 1 from the current item
- 'if its less then 0 we go to the END of the total count
- 'in this case that means item 3
- Sub object_ontimer200
- nItem = oItem - 1
- If nItem < 1 Then nItem = oCount
- CurItem = ObjName(oItem)
- NextItem = ObjName(nItem)
- If desktopx.Object(CurItem).left > EndPos Then
- desktopx.Object(CurItem).left = desktopx.Object(CurItem).left - (10 * ScaleFactor)
- DesktopX.Object(CurItem).opacity = DesktopX.Object(CurItem).opacity - FadePercent
- desktopx.Object(NextItem).left = desktopx.Object(NextItem).left + (10 * ScaleFactor)
- DesktopX.Object(NextItem).opacity = DesktopX.Object(NextItem).opacity + FadePercent
- Else
- oItem = oItem - 1
- If oItem < 1 Then oItem = oCount
- object.KillTimer 200
- End If
- End Sub
- Function ScaleMe()
- For x = 1 To ObjCnt
- desktopx.Object(ObjName(x)).resize (ObjWidth(x) * ScaleFactor),(ObjHeight(x) * ScaleFactor)
- If ObjMove(x) = True Then
- desktopx.Object(ObjName(x)).top = ObjTop(x) * ScaleFactor
- desktopx.Object(ObjName(x)).left = ObjLeft(x) * ScaleFactor
- End If
- Next
- EndPos = (MasterEndPos * ScaleFactor)
- End Function
if all your sliding objects are named using the same Item01, Item02, Item03, etc you could use this:
- '-- 3 is our max item count
- for x = 1 to 3
- t = x
- if x < 10 then t = "0" & x
- ObjCnt = ObjCnt + 1 : ObjName(ObjCnt) = "Target" & t
- ObjTop(ObjCnt) = 0 : ObjLeft(ObjCnt) = 0
- ObjWidth(ObjCnt) = 400 : ObjHeight(ObjCnt) = 180
- ObjMove(ObjCnt) = False
- 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.
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.
Reply #19 Thursday, February 19, 2009 7:43 PM
Amen Brother! This will be awesome, look forward to it, Po! ![]()
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 Tuesday, February 17, 2009 5:39 AM
I'm as confused as a baby in a topless bar!