Hi
When I try to use two animations (gif) at same time I get "java.lang.ArrayIndexOutOfBoundsException' . I used two different timers and a Frame2 var -unable to run both a same time. Independent they both work. I must be missing something (Newbe to B4A)
Sub Process_Globals
Dim Timer1 As Timer
Dim Frame As Int
Dim Timer2 As Timer
Dim FrameB As Int
Timer1.Initialize("Timer1",0)
Timer2.Initialize("Timer2",0)
End Sub
Sub Bore
gif.DisposeFrames
gif.Load(File.DirAssets, "Bore.gif")
FrameB = 0
Timer2.Interval = gif.Delay(FrameB)
imgBore.Bitmap = gif.Frame(FrameB)
Timer2.Enabled = True
gif.SaveFrame(0, File.DirRootExternal, "frame0.png", "P", 85)
gif.SaveFrame(0, File.DirRootExternal, "frame0.jpg", "J", 85)
End Sub
Sub Killer
gif.DisposeFrames
gif.Load(File.DirAssets, "Killerfish3.gif")
Frame = 0
Timer1.Interval = gif.Delay(Frame)
imgKillerFish.Bitmap = gif.Frame(Frame)
Timer1.Enabled = True
gif.SaveFrame(0, File.DirRootExternal, "frame0.png", "P", 85)
gif.SaveFrame(0, File.DirRootExternal, "frame0.jpg", "J", 85)
End Sub
Sub Timer1_Tick
Timer1.Enabled = False
Frame = Frame + 1
If Frame >= gif.FrameCount Then
Frame = 0
EndIf
Timer1.Interval = gif.Delay(Frame)
imgKillerFish.Bitmap = gif.Frame(Frame)
Timer1.Enabled = True
End Sub
Sub Timer2_Tick
Timer2.Enabled = False
FrameB = FrameB + 1
If FrameB >= gif.FrameCount Then
FrameB = 0
EndIf
Timer2.Interval = gif.Delay(FrameB)
imgBore.Bitmap = gif.Frame(FrameB)
Timer2.Enabled = True
End Sub