OK, i admit it. I’m probably the only person bothered by this. In the age of broadband where mobile phones browse the web at high speed, I’m probably a dinosaur for trying to keep movie file sizes down. But still. There still are people out there who browse the web at 56 kilobits per second, waiting for minutes while a web page full of graphics is transferred to their computer by two analog modems shouting bits at each other.
That’s one reason why I decided to see if re-writing my WP-Cumulus Flash movie in Actionscript 3 would yield a smaller file. Unfortunately, the outcome was not all I had hoped it to be.
Cleaning my cloud
AS3 is a far more efficient language than its predecessor, and I was hoping for a speed gain as well. Because I wanted a drop-in replacement for the old movie, I created a new movie with exactly the same features. Because AS3 is very much a different language, 90% of the code had to be rewritten to fit the new syntax. I switched to the new event handler thingy, used Sprites instead of heavier MovieClips, and cleaned up the code a bit.
When I compiled the movie I noticed a small drop in the size of the compiled actionscript code (from 2800 to 2300 bytes). This may be due to the fact that I dropped two 3rd party classes, and did some cleaning. But when I looked further down the size report, I found that the font I embedded was now taking up nearly 50% more space. The very same 484 glyphs were now adding over 27 kB to the swf file, instead of the 18 they were before.
What the font?
After a bit of testing I found out that this was due to the transition from Flash 7 to Flash 9. AS3 requires movies to target player version 9. Version 8 introduced a few new ways of anti-aliasing text, and apparently this requires the characters to be stored a little differently. As far as I can tell, setting a movie’s publish settings to version 8 or higher will cause a significant increase in file size if you’re using embedded fonts.
As for improved playback speed, I can’t really be sure. I ran both movies on my E6600 based Vista PC, and it seemed that the old AS2 version caused around 25% processor load. With the new movie it was 24%. Not a substantial drop, and well within the margin of error of my way of testing. The AS3 movie needs around 6.6 MB of memory, whereas the old one used 6.2. This surprised me a little, because Sprites were intended to safe memory over MovieClips, and I’m using lots of them.
I’m now contemplating whether I should release the new movie as part of the next WP-Cumulus release.
+ Optimized code
+ Minor speed improvement?
+ Better mouse exit detection (a new feature in AS3)
+ Easier to maintain
+ It’s done, and I like AS3 so far
- Larger file size
- Requires player version 9
Player 9 has been out for quite a while now, and even a Linux version is available. My stats tell me that well over 98% of my website’s visitors are using version 9. Still, the old movie does exactly the same thing the new one does. What do you think?