Animated Mouse-Over

Blitz3D Forums/Blitz3D Beginners Area/Animated Mouse-Over

Is there any way to animate an image when the mouse hovers over it? But I want the animation image to be of only 3 frames.
1 - The normal frame (no mouse over)
2 - The transition frame
3 - The hover frame (mouse over)

And when the mouse leaves the image:
1 - The hover frame (mouse over)
2 - The transition frame
3 - The normal frame (no mouse over)

Any suggestions or code?

Graphics 800,600,0,2
SetBuffer BackBuffer()

Dim buttonAnim(2)
For i=0 To 2
	buttonAnim(i)=CreateImage(32,32)
Next
Rect 0,0,32,32,True
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(0))
Cls : Rect 8,8,16,16,True
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(1))
Cls : Rect 8,8,16,16,False
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(2))

Global mouseHotSpot = CreateImage(1,1)
Rect 0,0,1,1,True : GrabImage mouseHotSpot,0,0

Type button
	Field xPos
	Field yPos
	Field frame
	Field transitionDelay
End Type
For i=0 To 3
	currentButton.button=New button
	currentButton\xPos=i*64
	currentButton\yPos=100
	currentButton\frame=0
	currentButton\transitionDelay=0
Next

While Not KeyHit(1)



For currentButton=Each button
	If ImagesOverlap (buttonAnim(currentButton\frame),currentButton\xPos,currentButton\yPos,mouseHotSpot,MouseX(),MouseY())
		If currentButton\frame=0
			currentButton\frame=1
			currentButton\transitionDelay=10
		Else
			If currentButton\transitionDelay>0 Then currentButton\transitionDelay=currentButton\transitionDelay-1
			If currentButton\transitionDelay=0 Then currentButton\frame=2
		EndIf
	Else
		If currentButton\frame=2
			currentButton\frame=1
			currentButton\transitionDelay=10			
		Else
			If currentButton\transitionDelay>0 Then currentButton\transitionDelay=currentButton\transitionDelay-1
			If currentButton\transitionDelay=0 Then currentButton\frame=0			
		EndIf
	EndIf
	DrawImage buttonAnim(currentButton\frame),currentButton\xPos,currentButton\yPos
Next
Flip
Cls
Wend