Moving to AS3 – what the font?

Flash font properties dialog

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.

Differences

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.

Speed

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.

So?

I’m now contemplating whether I should release the new movie as part of the next WP-Cumulus release.

Pro:
+ 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

Con:
- 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?

5 Comments

  1. Is there not the option of releasing alongside the current release?

    Those who prefer smaller filesize over optimization would be as happy as the optimization over filesize group.

    Comment by Michael Robinson — June 18, 2008 @ 8:48 pm

  2. That would be an option, but if I do that, I’ll have to add future enhancements to both movies. In fact, there’s already a few tricks in the AS3 version that the AS2 one can’t do.

    Comment by Roy — June 19, 2008 @ 8:19 am

  3. imho there’s no strong difference in size – of course, it would take some time before it is cached, but it would draw all that fonts faster – imho it is more important.

    by the way, i’m glad there’s someone who still thinks of people with 56kbps)) there’s been time i had 28kbps – that was really killin thing

    Comment by Ivan Matveyev — August 1, 2008 @ 2:47 pm

  4. I think it’s more important to keep the speed up.

    The older computers must be capable to run your flash app.

    Comment by Gert — August 2, 2008 @ 5:05 pm

  5. The last two pro’s you mentioned are the most important to keep up your fine Open Source work. So I’d say: step into AS3 with WP-Cumulus.

    Comment by Eelco — August 5, 2008 @ 9:52 am