Embed Images as binaryData in AS3 to reduce SWF size
This evolved from a lengthy discussion on the file size of an SWF.
It seems that Flash/Flex embeds PNGs as 32bit only. And this in some cases causes the size of the image to be greatly increased. In some cases the size of the image more than doubles if the image had been compressed using optimization utilities.
The solution to keep the reduced size that I came up with is to embed the image as binaryData instead of a bitmap using the mimeType='application/octet-stream' like this
[Embed(source = "assets/8bit.png", mimeType = "application/octet-stream")] public static const IMG:Class; |
But this gives us a ByteArray instead of the needed bitmap.
This ByteArray can be decoded into a bitmap using the Loader.loadBytes() function, but this function is asynchronous and thus this step needs to be performed in advance, during initial game loading.
For this I have made the following OctetStreamBitmapDecoder class
Categories
Recent Posts
- Embed Images as binaryData in AS3 to reduce SWF size
- Syllabus of 8th Semester CSE
- Using CppUnit with Visual Studio
Archives
- November 2012 (1)
- January 2010 (1)
- November 2009 (1)
Tags
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
« Nov | ||||||
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |