Flash-Animated-GIF-Library is a fast and robust library for playing Animated GIFs. Its parser is quite strict, however, so if there is a GIF that works in the browser but not with this library it probably means the browser is being overly lenient with the corrupt image data.
The speed gains are achieved by specifically avoiding doing any pixel decoding at all and instead splitting and re-packaging each frame of the animation into its own freestanding gif file. The resulting single-frame GIF files are handled to Flash to decode the frame’s image data internally via the Loader class.
Sample
var player:GIFPlayer = new GIFPlayer(); gifContainer.addChild(player); player.smoothing = false; player.addEventListener(GIFPlayerEvent.COMPLETE, handleGifLoadComplete); player.addEventListener(AsyncDecodeErrorEvent.ASYNC_DECODE_ERROR, handleAsyncDecodeErrorEvent); player.addEventListener(GIFPlayerEvent.FRAME_RENDERED, handleFrameRendered); player.loadBytes(file.data); private function handleAsyncDecodeErrorEvent(event:AsyncDecodeErrorEvent):void { trace("GifPlayer: Async Decode Error Event: " + event.text); } private function handleGifLoadComplete(event:GIFPlayerEvent):void { trace("Gif load complete, adding to stage"); } private function handleFrameRendered(event:GIFPlayerEvent):void { trace("Frame " + event.frameIndex + " rendred."); }
Andrey Kyznetsov liked this on Facebook.
Jakub Wagner liked this on Facebook.
RT @as3gamegears: New: Flash-Animated-GIF-Library (fast and robust lib for playing GIFs in #Flash.) http://t.co/3uDxwzdOen #as3 #gamedev