Page 1 of 1
Control play of GIF
Posted: Thu May 17, 2012 1:21 am
by FrankR
How do I
- Play the animation of a GIF just once and stop
- Repeat the play programmatically?
Thank you.
Re: Control play of GIF
Posted: Thu May 17, 2012 1:50 am
by sturgis
look in the dictionary at repeatcount, framecount and current frame.
repeatcount says how many times the gif should loop the animation (natively, so to have it play once set the repeatcount to 1)
framecount returns the number of frames that the gif contains.
currentframe is of course the currently showing frame.
So, if you set the repeatcount to 1 the gif will stop animating after the first time through. Then if you want to animate it yourself 1 time through the animation something like the following should work.
repeat with i = 1 to the framecount of image "imagename"
set the currentframe of image 1 to i
wait 100 milliseconds with messages -- adjust this number as needed to get the frame flip speed desired
end repeat
Re: Control play of GIF
Posted: Sat May 19, 2012 3:05 pm
by FrankR
That's extremely helpful. Thank you. I will go experiment.
Isn't there a way, though, to repeat the whole animation without a loop.
I could see needing the loop to play a segment of a GIF. But to just replay the whole GIF, there isn't
a way to do that without controlling the animation with a loop?
Re: Control play of GIF
Posted: Sat May 19, 2012 3:36 pm
by sturgis
Every time you set the repeatcount of the image it will play that many times.
So if the image is stopped and you then set the repeatcount of image "imagename" to 1, the animation will play 1 time.
Re: Control play of GIF
Posted: Sat Jul 26, 2014 6:24 am
by William Jamieson
2 years later stumbled upon this post...
the answer is to set the repeat count to a negative number and it will play indefinitely