It depends on exactly how you create the avatar in Flash. By coincidence, my group developed a demo application which does just like that. It is called FunIcons, you can select a character and then create an animation by drawing a path on the face with the mouse (press and hold the mouse button to do so), and then by clicking on the "Save" button, you will get an animated gif with the sequence you just plotted.
The trick is simple: a PHP script on the server side takes the sequence of GIF files that build up the animation, and constructs an animated GIF from them. Here's the script itself:
<?php
header ("Content-type: image/gif");
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header ("Content-Disposition: attachment; filename=\"funicons.gif\"");
require_once "GifBuilder/GIFEncoder.class.php";
$path = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
$i = strrpos($path, "/");
$path = substr($path, 0, $i+1);
$images = split(",", $_REQUEST["images"]);
$prevUrl = "";
while (list ($key, $val) = each($images))
{
if (substr($val, 0, strlen($path)) == $path) $val = substr($val, strlen($path));
if ($val == $prevUrl)
{
$delay[count($delay)-1] += 10;
} else {
$frames[] = file_get_contents($val);
$delay[] = 10;
$prevUrl = $url;
}
@set_time_limit(30);
}
$gif = new GIFEncoder ( $frames, $delay, 0, 2, -1, -1, -1, "bin" );
print($gif->GetAnimation());
?>