views:

30

answers:

1

I was trying to further reduce the filesize of a SWF file by optimizing the embedded PNG graphics (using ImageOptim tool). To my surprise, this didn't yield any effect, so I created two test Images (get them here: http://www.filefront.com/16902865/images.zip):

Original (434kb)

Optimized (274kb)

When embedding either of these assets in a simple ActionScript project, the compiled SWF is 274kb in size. Which raises the question: Does Flex optimize embedded PNG assets during compile-time? If yes, is there some documentation about the optimization going on? It can't be because of the SWF compression alone, because zipping the images doesn't reduce filesize at all.

Here's the Code for completeness:

package
{
    import flash.display.Sprite;

    public class SizeTest extends Sprite 
    {
        [Embed("/assets/original.png")]
        private var ImageAsset:Class;

        public function SizeTest(){
        }
    }
}
A: 

The swf format has internally a special format for 32 bit PNGs (those with an alpha channel) where they get split up into a 24bit png and a greyscale alpha mask, whereby the alpha mask gets JPEG compressed. No totally sure if Flex Builder does that kind of optimization since I remember that at least in an older version embedded PNG where not at all optimized.

Nevertheless, if you are looking for a tool that can optimize embedded images in swfs you should check out Joa Ebert's "Reducer": http://blog.joa-ebert.com/2009/08/08/reducer/

Quasimondo
Thanks for your answer.I'm aware of the PNG compression in the Flash IDE. But AFAIK this only applies to the Flash IDE and not Flex.I also know Joa Ebert's Reducer... but I'm still wondering why the compiled SWF filesize is basically the same for both images (only off by a few bytes)
bummzack