Hey geeks,
Today I will show you how to load animated gifs into your flash movie or flex application. To my and maybe also to your suprise Flash and Flex does not have this function natively. To extend your application with this feature you must download an extern library. I used AS3GIF which is a free library that works great for me. It also includes a GIF encoder which allows you to frame by frame animations from a movieclip for instance.
You can download the source of this project right here
Howto:
After you have downloaded the library, and extracted to your root folder of your project, you import it to enable this library into your project
import org.bytearray.gif.player.GIFPlayer;
Next you create an instance of the GIFPlayer Class and set the url of the animated gif and you added to the stage.
gif.load(new URLRequest("ajax-loader.gif"));
uic.addChild(gif);
That’s it folks! It is that easy to use animated GIF’s in flex or flash. When you want to load gifs into flex you have to add the gif instance to an UIComponent. Because flash has no actual stage instance…
Have fun coding and experimenting
Lode
Btw: Thanks to thibault.imbert for this great library, check various of other library he’s made at this url
Error de conversión forzada: no se puede convertir org.bytearray.gif.player::GIFPlayer@8b23381 en mx.core.IUIComponent.
Could you please post me your source code and some info? If you could try to speak english on this blog
nice! but can you show me how to add gif component on flex please
@raksmey
the way explained in this tutorial is how I did it in flex. Do not forget to add an UIcomponent to your flex form else you will not be able to use the .addChild method.
It’s work perfectly fine. Thanks for your viable solution.