Published on September 26, 2006 By Murex In DesktopX
This is a script that I have used on some of my themes It works fairly good but one draw back is that the button to roll or unroll has to be on the roll up object. I would like to have the button located on another object I have tried to modify the script my self with out any luck. I was wonder if any one can help me with this.. Also was wondering if the text can be made to fade in and out as the menu rolls up and down.. I know that this can be done, Question is can it be done in a way that it would be easy for other people to edit it so that they can add or subtract text from it... any help with this would be greatly appreciated



Dim ulRolledUpSize
Dim ulExpandedSize
Dim ulSpeed
Dim Lock

ulRolledUpSize = 42 'This sets the size you want your parent object to rollup to.
ulExpandedSize = 234 'This sets default the size you want your parent object to rolled down
ulSpeed = 30 'This sets the # of frames you want it to take to role up or down

Sub Object_OnScriptEnter
Object.StatePreempt = Object.PersistStorage("State")
End Sub


'****************************************************************************************************************

Sub Object_OnLButtonDown(x,y) 'When this object is clicked.
If Lock Then Exit Sub
If Object.PersistStorage("State") = "Up" Then 'Check to see if we are Rolled Down.
Rollup() 'If it is, Call the Rollup sub.
Else 'If Not
Rolldown() 'Call the Rolldown Sub.
End If

End Sub

'****************************************************************************************************************

Sub Rollup()

Lock = True

'ulExpandedSize = Object.Parent.Object.Height 'Set the current size as the Expanded size
Object.StatePreempt = "Down" 'Change the image state to 'down'
Object.PersistStorage("State") = "Down"

Do While Object.Parent.Object.Height > ulRolledUpSize 'Size the image down, in # of Frames set in ulSpeed
Object.Parent.Object.Height = Object.Parent.Object.Height - ((ulExpandedSize - ulRolledUpSize) / ulSpeed)
Object.Sleep 10 'Pause for a bit between frames.
Loop

Object.Parent.Object.Height = ulRolledUpSize 'Make sure the Final size is Correct.

Lock = False
End Sub

'****************************************************************************************************************

Sub Rolldown()
If Lock Then Exit Sub
Lock = True
Object.StatePreempt = "Up" 'Change the image state to 'up'
Object.PersistStorage("State") = "Up"

Do While Object.Parent.Object.Height < ulExpandedSize 'Size the image up, in # of Frames set in ulSpeed

Object.Parent.Object.Height = Object.Parent.Object.Height + ((ulExpandedSize - ulRolledUpSize) / ulSpeed)
Object.Sleep 10 'Pause for a bit between frames.
Loop

Object.Parent.Object.Height = ulExpandedSize 'Make sure the Final size is Correct.
Lock = False
End Sub
Comments
on Sep 26, 2006
in order for one object to control another object you need to use:

desktopx.object("name").
where "name" is the name of the object you want to control.


I would have ALL of the above code in the button, not the rollup/down object.
Assuming the ROLLUP objects' name is "ROLLOBJ"

It would change like this: (im not editing it all, but this should help)

Sub Object_OnScriptEnter
desktopx.Object("ROLLOBJ").StatePreempt = desktopx.Object("ROLLOBJ").PersistStorage("State")
End Sub


'****************************************************************************************************************

Sub Object_OnLButtonDown(x,y) 'When this object is clicked.
If Lock Then Exit Sub
If desktopx.Object("ROLLOBJ").PersistStorage("State") = "Up" Then
Rollup()
Else
Rolldown() 'Call the Rolldown Sub.
End If
End Sub
(i like indented IF's so i can see them closed)


'****************************************************************************************************************

Sub Rollup()
Lock = True
desktopx.Object("ROLLOBJ").StatePreempt = "Down" 'Change the image state to 'down'
desktopx.Object("ROLLOBJ").PersistStorage("State") = "Down"
Do While Object.Parent.Object.Height > ulRolledUpSize
desktopx.Object("ROLLOBJ").Parent.Object.Height = desktopx.Object("ROLLOBJ").Parent.Object.Height - ((ulExpandedSize - ulRolledUpSize) / ulSpeed)
desktopx.Object("ROLLOBJ").Sleep 10 'Pause for a bit between frames.
Loop
desktopx.Object("ROLLOBJ").Parent.Object.Height = ulRolledUpSize 'Make sure the Final size is Correct.
Lock = False
End Sub

Hope this makes some sense.
If not, email me the objects and ill make it work.

---- time for another tutorial? ----
on Sep 26, 2006
Thanks for helping me out I did recive a couple of errors and was able to figure it out but not sure what to do about this error..



on Sep 26, 2006
Ok got that last error figured out.. I don't get any more errors but I can't get it to work.. here is what i have for he script now .. Not sure what to do about the parent part..


Dim ulRolledUpSize
Dim ulExpandedSize
Dim ulSpeed
Dim Lock

ulRolledUpSize = 42 'This sets the size you want your parent object to rollup to.
ulExpandedSize = 234 'This sets default the size you want your parent object to rolled down
ulSpeed = 30 'This sets the # of frames you want it to take to role up or down




'****************************************************************************************************************

Sub Object_OnScriptEnter
desktopx.Object("ROLLOBJ").StatePreempt = desktopx.Object("ROLLOBJ").PersistStorage("State")
End Sub


'****************************************************************************************************************

Sub Object_OnLButtonDown(x,y) 'When this object is clicked.
If Lock Then Exit Sub
If desktopx.Object("ROLLOBJ").PersistStorage("State") = "Up" Then
Rollup()
Else
Rolldown() 'Call the Rolldown Sub.
End If
End Sub


'****************************************************************************************************************

Sub Rollup()
Lock = True
desktopx.Object("ROLLOBJ").StatePreempt = "Down" 'Change the image state to 'down'
desktopx.Object("ROLLOBJ").PersistStorage("State") = "Down"
Do While Object.Parent.Object.Height > ulRolledUpSize
desktopx.Object("ROLLOBJ").Parent.Object.Height = desktopx.Object("ROLLOBJ").Parent.Object.Height - ((ulExpandedSize - ulRolledUpSize) / ulSpeed)
desktopx.Object("ROLLOBJ").Sleep 10 'Pause for a bit between frames.
Loop
desktopx.Object("ROLLOBJ").Parent.Object.Height = ulRolledUpSize 'Make sure the Final size is Correct.
Lock = False
End Sub


'****************************************************************************************************************

Sub Rolldown()
If Lock Then Exit Sub
Lock = True
Object.StatePreempt = "Up" 'Change the image state to 'up'
Object.PersistStorage("State") = "Up"
End Sub