Flash-Animated-GIF-Library icon indicating copy to clipboard operation
Flash-Animated-GIF-Library copied to clipboard

Not playing if add to stage after decode complete

Open shunia opened this issue 9 years ago • 1 comments

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:

  1. remove the stage check inside function handleDecodeComplete (GIFPlayer.as) :
  - if (stage) {
       if (autoPlayer) {
       ...
  - }
  1. 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.

shunia avatar Nov 04 '15 08:11 shunia

And a second solution is add codes inside the function initMinFrameDelay to trigger the first play.

shunia avatar Nov 04 '15 08:11 shunia