How do I
- Play the animation of a GIF just once and stop
- Repeat the play programmatically?
Thank you.
Control play of GIF
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Control play of GIF
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
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
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?
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
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.
So if the image is stopped and you then set the repeatcount of image "imagename" to 1, the animation will play 1 time.
-
- VIP Livecode Opensource Backer
- Posts: 212
- Joined: Fri Feb 01, 2013 1:31 am
- Location: Palo Alto, CA put williamdjamieso into tEmail / put n@gmail.com after tEmail/ revmail tEmail
- Contact:
Re: Control play of GIF
2 years later stumbled upon this post...
the answer is to set the repeat count to a negative number and it will play indefinitely
the answer is to set the repeat count to a negative number and it will play indefinitely