Loading Animated GIF in Flex

September 30, 2008

Loading Animated GIF in Flex is something that has always been the most wanted thing for Flex Developers. Doug McCune has made a component, Animated GIF Loader which actually loads animated gif. But the only drawback is that it costs $50!

Here is a free solution. There is a free component AS3GIF. The example shown with the code was made in Flash CS3. I ported it for Flex. Here is a sample…

Run Demo
Download Source | [Google Pages Mirror Link] | [Freehostia Mirror Link]

P.S: As many of you have reported that the 10gbfreehost link doesn’t seem to work, I have added a few other mirrors where I have uploaded the source zip file. One of them should definitely work!



  1. many thanks for the code! I have been looking for a cheaper alternative to AS3Gif for a long time!

  2. Thank you for a very helpful feature.

    I know almost zero about GIF file formats, so this is probably my error, but I thought I’d pass it along in case there is some debugging to be done.

    01. I found a gif file which looked pretty good, but did not really have the correct encoding for transparency, so the rotations were a bit ugly around the edges.

    02. I found some old software from Jasc that supports creation of animatied gifs, so I used it to clean up the transparency problem. Now, however, the rotations, while clean around the edges, did not properly transit from image to image.

    03. I found some code in your readHeader routine that relate to ‘dispose’ methodology. The first file — the one that sort of worked, but was ugly — had 8 frames all coded 1. The second file — the one with improper bitmap transitions was coded as dispose = 2 on the first 7 frames and 1 on the final frame.

    04. Blindly knowing nothing, I forced your code to treat all 8 frames as dispose mode 2, and then the transitions were correct. I’m sure my ‘fix’ is not generically correct at all, but I think the use case with a dispose mode 1 at the end of previous dispose mode 2 frames will always fail because of some logic I swiftly passed by which carries the ending disposal mode forward to the start of the next loop.

  3. […] Flex, How to load animated GIFs using Adobe Flex By goelnitin https://flexology.wordpress.com/2008/09/30/loadinganimated_gif_in_flex/ […]

  4. Hi i have experience with gif in other languages and i realized that they are not time based animation.So its speed depends from the client machine.It means that in differents computers it is going to see different.Eihter more fast or more slow.
    That is anoying.i am investigating if this components solve this problem.Tell me something if you know.

    • Hi there… year animated gif is not like timeline based animations (precisely Flash SWFs) because SWFs are rendered by Flash Player and GIF is rendered by the browser. The rendering by the browser depends on the capability of the browser and the processing power of the computer. AFAIK, the GIF will run normally on a high-end machine, but it runs slowly on a machine with old configuration.

      This component should solve your problem because the GIF is loaded in to the Flash Player and then Flash Player runs the GIF. So, now the responsibility of rendering the GIF is of the Flash Player and not the browser. Theoretically it should work! But anyways let us know the results…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: