Gif decoder error - arrayindexoutofboundsexception

shrz

Member
Licensed User
Longtime User
Can someone please help with my code, cannot work out why this keeps falling over on one particular gif - Car.gif - have tried using the debugger

if you run open each icon in order, aeroplane, ball, boy and let the animation play other wise i get an illegalstateexception interval must be larger than zero, if opening and going back to back menu without letting the animation complete, any advice on how to handle this? such as handling exception to clear the interval after clicking back?


if you continue to car after boy, you get an arrayindexoutofboundsexception.

is this because of the number of frames or speed on this particular gif?

any help would be much appreciated, the code is quite messy as ive tried a few things to get this work including a few extra initializes!!

if anyone is able to crack this, can you also explain how you debugged this or at least what you watched with the debugger to work it out?

many thanks.
 

agraham

Expert
Licensed User
Longtime User
You need to use a new instance of GifDecoder for each image. You can't load a new image on top of another one as the Load method does not do a full re-initialisation, mainly because I was too lazy to type it all in.

Also you don't need to use CallSub to call within a module - it is inefficient. Just call the Sub directly.
B4X:
Sub iaero_Click
   [COLOR="Red"]ani[/COLOR]
   gif.DisposeFrames
   [COLOR="red"]Dim gif As GifDecoder[/COLOR]
   gif.Load(File.dirassets, "aero.gif")
   ...
 
Upvote 0
Top