Flash-Animated-GIF-Library
Flash-Animated-GIF-Library copied to clipboard
Not playing if add to stage after decode complete
It's actually a bug which can be triggered like this:
var gif:GIFPlayer = new GIFPlayer();
gif.addEventListener(GIFPlayerEvent.COMPLETE, function (e:*):void {
addChild(gif);
};
gif.loadBytes(gifDataBytes);
As I tried, two lines' modification should fix this:
- remove the stage check inside function
handleDecodeComplete
(GIFPlayer.as
) :
- if (stage) {
if (autoPlayer) {
...
- }
- add a stage check inside function
goto
(GIFPlayer.as
) :
+ if (stage == null) return;
_cuirrentFrame = requestedIndex;
...
And another problem is that the function goto
need to change it's name into something like gotoFrame
or it will cause error when compiling in lots of flashplayer compile targets.
This is a great project which really properly handled gif files, and is better than the version you can find on the internet written by "bytearray"(?).Thanks and I'm using this lib in a business project.
And a second solution is add codes inside the function initMinFrameDelay
to trigger the first play.