Create the following four states:
1. open
2. closed
3. aniopen
4. aniclosed
Set "aniopen" state to your animated png and set to forward(assuming forward means open)
Set "aniclosed" state to your animated png and set to backward(assuming backward means close)
Set "open" state to the image when open.
Set "closed" state to the image when closed.
*Note: This could be done with two or three states but, trying to keep this simple.
Here's the script:
The speed of the timers on line 15 and 19 is the speed of your animation. For example this script use a 19 frame png with 25ms per frame for a total of 475ms.
Code: vbscript
- Dim blnOpen
- 'Called on selected object state changes
- Function Object_OnStateChange(state)
- If state= "Mouse up" Then
- Call Animation(state)
- ElseIf state="open" Then
- Object.KillTimer 1
- ElseIf state="closed" Then
- Object.KillTimer 2
- End If
- End Function
- Function Animation(state)
- If blnOpen Then
- Object.State="aniclosed"
- Object.SetTimer 2,480
- blnOpen=False
- ElseIf Not blnOpen Then
- Object.State="aniopen"
- Object.SetTimer 1,480
- blnOpen=True
- End If
- End Function
- 'Called when the script is executed
- Sub Object_OnScriptEnter
- Object.State="open"
- blnOpen=True
- End Sub
- Sub Object_OnTimer1
- Object.State="open"
- End Sub
- Sub Object_OnTimer2
- Object.State="closed"
- End Sub