There are a few ways to do what you want. I didn't test this code however I'm sure that it will work.
Dim num,td '<== frame number and time delay
Sub Object_OnLButtonUp(x,y,dragged)
If Not dragged Then
num = 1 : SetKey(1)
End If
End Sub
Sub SetKey(n)
Select Case n
Case 1 td = 200
Case 2,3,4,5 td = 10
Case 6 td = 100
Case 7,8,9 td = 10
Case 10 td = 12
Case 11 td = 15
Case 12 td = 25
Case 13,14 td = 8
Case 15,17 td = 0
Case 16 td = 6
Case 18,19,20 td = 5
End Select
If td > 0 Then Object.SetTimer 1,td Else Object_OnTimer1
End Sub
Sub Object_OnTimer1
Object.KillTimer 1
desktopx.object("frame").state = num '<== state names from 1 to 20
If num < 20 Then num = num + 1 Else num = 1
Call SetKey(num)
End Sub
As well as you may create the array with path to each of your images:
Dim frame(20),num,td
Sub Object_OnScriptEnter
For n = 1 To 20
frame(n) = "C:\My Pictures\image"&n
Next
End Sub
then use this code to change frames:
Sub Object_OnTimer1
Object.KillTimer 1
desktopx.object("frame").picture = frame(num)
If num < 20 Then num = num + 1 Else num = 1
Call SetKey(num)
End Sub
Best Regards.