Today I tried to load a animated loading animation as a gif image into the Flash Player and discovered that he is not able to play them. It only shows the first frame.
My loading.gif:
So how to convert this gif animation into a swf file, which the Flash Player could play? (And of course I only want to use open source tools.) It was very easy:
- Make sure you have ImageMagick installed.
- Open a console and go to the directory where the gif file is located:
convert +adjoin -coalesce loading.gif frame%02d.png
- Now we have a png for every frame of the gif animation. Why png? Because swfmill does not support gif as file format and png it the only available format with support for transparency.
- Create a XML file that look similar to this one:
-
<?xml version="1.0" encoding="utf-8" ?>
-
<movie width="32" height="32" framerate="25">
-
<background color="#ffffff"/>
-
<frame>
-
<library>
-
<clip id="frame00" import="frame00.png"/>
-
</library>
-
<place id="frame00" depth="1"/>
-
</frame>
-
<frame>
-
<library>
-
<clip id="frame01" import="frame01.png"/>
-
</library>
-
<place id="frame01" depth="1"/>
-
</frame>
-
<frame>
-
<library>
-
<clip id="frame02" import="frame02.png"/>
-
</library>
-
<place id="frame02" depth="1"/>
-
</frame>
-
….
-
</movie>
-
- Finally merge the single frame images together with swfmill:
swfmill simple input.xml output.swf
- That’s all.
Comments