I have to admit that I just love animated GIF's, it reminds me the old school days playing the SNES ;)

Recently I found a java GIF encoder and decided to implement it in AS3, ok maybe some people will say it's just unuseful but here it is, I love it !

Everything is encoded through the player. Then you know the story, the GIF stream is sent through AMFPHP to a server to download it, and then save it to your hard disk. Any kind of images can be included in the final GIF, each frame is a flash.display.BitmapData object.

I'll post the sources in a few days, I want to add some more features, stay tuned !

Piterwilson did a funny experiment with this and the GIFPlayer class.

Here is how to generate an animated GIF stream in ActionScript 3 :

// we create the GIF encoder
var myGIFEncoder:GIFEncoder = new GIFEncoder();
// we call the start method to start a new GIF file stream
// we call the setRepeat method with 0 as parameter so that it loops
//we specify each frame delay in ms before each addFrame call
myGIFEncoder.setDelay ( 100 );
//we add each BitmapData as frames with the addFrame method
myGIFEncoder.addFrame( new BitmapData ( 200, 200 ) );
// we finalize the GIF stream by calling the finish method
// then you retrieve the GIF ByteArray with the stream getter
var myGIFStream:ByteArray = myGIFEncoder.stream;

Online Demo :

A Flash animation should have appeared here, but it seems that your browser has an older version of the Flash Player or it is not installed at all. Please, install the last release of the Flash Player now, then reload this page.

The GIF Encoder looks nice on the Web Flash Festival 2007 screen :)

GIF Encoder on Screen

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.

Sources and documentation available at http://code.google.com/p/as3gif/