The Flash Player does not offer native support for animated GIF files. In the DHTML runtime, you can just use an animated GIF like any other image resource. But how can an image be used as a resource for a view in the SWF10 or SWF11 runtime?
Share
Luckily there are a number of existing open source ActionScript libraries with support for playing and generating animated GIFs. We are going to use the as3gif project. We first have to compile the ActionScript source code of as3gif into an SWC library, which then can be used with OpenLaszlo. Download the ZIP file with version 0.6 of as3gif. Extract the ZIP file in your $LPS_HOME folder. You should have a subfolder “GIFPlayer 0.6”.
Go into that folder, and use the Flex SDK compc command to compile the ActionScript classes into an SWC file. For OpenLaszlo 4.9 or 5.0 (as of September 2012), the compc command can be found in $LPS_HOME/WEB-INF/bin/compc. If you use the flex4.6 branch of OpenLaszlo, the path to the compc command is either WEB-INF/flexsdk/4.5.1/bin/compc for the SWF10 runtime, or WEB-INF/flexsdk/4.6.0/bin/compc for the SWF11 runtime.
After the compilation, you will find the generated SWC file in the subfolder bin:
Copy the SWC file into your $LPS_HOME/WEB-INF/flexlib folder. The class which we are going to use to display an animated GIF is the org.bytearray.gif.player.GIFPlayer class.
Here is an example of an OpenLaszlo class supporting GIFs in both runtimes:
The ActionScript class supports starting and stopping animation, and gives you access to the delay for each frame of the GIF.