As I use Tombalachi's
Hiding Menu Script quite a bit I've revised and cut 20 lines of code. Since his email seems to be dead I thought I'd post my revised script here. My suggestion is to download his original in order to understand this a bit better.
Code: vbscript
- '--Note the With Statement is only used where the savings are obvious
- '----------CUSTOMIZE HERE----------
- Const hideTop = -160,hideLeft = -160,hideSpeed = 10,hideDelay = 700,_
- showTop = -50,showLeft = 0,showSpeed = 16
- '-----------END CUSTOMIZE----------
- Dim delay
- 'Called when the script is executed
- Sub Object_OnScriptEnter
- delay = 0
- 'Timer for hiding the object
- Object.SetTimer 4321, 100
- End Sub
- 'Called when the script is terminated
- Sub Object_OnScriptExit
- Object.KillTimer 4321
- Object.KillTimer 1234
- End Sub
- Sub Object_OnStateChange(state)
- With Object
- If state = "Mouse over" Then
- 'Kill the hide timer
- .KillTimer 4321
- 'Start the show timer
- .SetTimer 1234, 100
- Else
- 'Kill the show timer
- .KillTimer 1234
- 'Start the kill timer
- .SetTimer 4321, 100
- End If
- End With
- End Sub
- Sub Object_OnTimer1234
- 'Show the object
- Call MoveIt(showTop, showLeft, showSpeed)
- If (Object.Top = showTop) And (Object.Left = showLeft) Then
- delay = hideDelay
- End If
- End Sub
- Sub Object_OnTimer4321
- 'Hide the object
- If delay <> 0 Then
- 'We wait until delay is over
- delay = delay - 100
- Else
- Call MoveIt(hideTop, hideLeft, hideSpeed)
- End If
- End Sub
- Sub MoveIt(destTop, destLeft, speed)
- With Object
- 'Are we there yet?
- If (.Top <> destTop) Or (.Left <> destLeft) Then
- 'Go ahead and hide
- Dim diffTop,diffLeft,distance,speedTop,speedLeft
-
- diffTop = destTop - .Top
- diffLeft = destLeft - .Left
- distance = (diffTop^2 + diffLeft^2)^0.5
- speedTop = speed * diffTop / distance
- speedLeft = speed * diffLeft / distance
-
- If Abs(speedTop) > Abs(diffTop) Then
- speedTop = diffTop
- End If
- If Abs(speedLeft) > Abs(diffLeft) Then
- speedLeft = diffLeft
- End If
-
- .Move .Left + speedLeft, .Top + speedTop
- End If
- End With
- End Sub