Why do gif's always go bad in my apps..?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Why do gif's always go bad in my apps..?

Post by doobox » Mon Mar 18, 2013 11:29 pm

Hi there,

I always seem to have problems with gif image spinners in my apps.

So for example, i have a gif spinner image with the visible set to false.
Then set the visible to true breifly during some process.

At first the spinner always works and spins correctly. But at some point after using the app over time, the image always becomes stuck on on frame, and thus shows but no longer spins.
How are my apps always breaking my animated gif images..?
Kind Regards
Gary

https://www.doobox.co.uk

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Why do gif's always go bad in my apps..?

Post by sturgis » Mon Mar 18, 2013 11:40 pm

Look at repeatcount in the dictionary. SPecifically setting the repeatcount to a negative number.

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Why do gif's always go bad in my apps..?

Post by doobox » Mon Mar 18, 2013 11:55 pm

Thank you..

I was not to sure what that repeat was in the inspector for the image, but do recall it set to -1
Just checked, and it was set to 1
It looks like importing a new spinner, sets the repeat to -1 by default, but somewhere along the line it gets switched to 1
I will keep an eye on it.

Do you think setting the repeat count of the image via script could make a difference..?
Kind Regards
Gary

https://www.doobox.co.uk

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Why do gif's always go bad in my apps..?

Post by sturgis » Tue Mar 19, 2013 12:05 am

it might. If it is ending up set at one it will basically go through the images a single time and stop. Not sure why it would change to 1 from -1 but manually setting it when you make the image visible isn't a bad idea. Animated gifs eat cpu so if it were me I'd set it to 0 when invisible and -1 when visible so that its only animated when you want it to be. You can also set the framecount to 1 to start at the beginning again.

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Why do gif's always go bad in my apps..?

Post by doobox » Tue Mar 19, 2013 12:11 am

Year, that sound like a good idea. It will both ensure i get proper animation as well as saving cpu as you point out.
Thanks again (great i now understand how LC handles gifs) :-)
Kind Regards
Gary

https://www.doobox.co.uk

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Why do gif's always go bad in my apps..?

Post by jacque » Tue Mar 19, 2013 7:32 am

You should be able to set the gif to -1 and leave it that way. I don't think the engine draws it when it isn't visible so it won't use any of the CPU.

If you are in a long process then the engine will be too occupied to draw the frames. That can happen especially in repeat loops. Add this inside the loop to give the engine time to update the gif:

Code: Select all

wait 1 millisecond with messages
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Why do gif's always go bad in my apps..?

Post by sturgis » Tue Mar 19, 2013 2:31 pm

Ah k. Wasn't sure if it was still flipping through frames when it was invisible. Even if it is, not having to draw them would still be the main benefit. Thx for the clarification!

Post Reply