I expect every flash developer reaches a point where they’re ambitions bump up against the limitations of what the flash player can actually do. With every new version of flash the ceiling may get a little higher but it doesn’t take long for the community to start banging their heads again.
Some of the most interesting flash work out there has to be by those developers who can push the platform that little bit further; thankfully a lot of them are willing to share their techniques.
In this article, I thought I’d pull together some of the advice on optimisation I’ve picked up from blogs, conferences, comments and books.
My earliest exposure to data structures and optimisation came from Polygonal labs. The blog is immensely informative. Here are some of the best articles for understanding optimisation:
- Explains the int, uint and number data types and which to use and when
- Bitwise gems for fast math
- Fast sin/cosine approximation
- Object pools
Data structures and motor2 are both really good libraries and worth checking out, too.
Joa Ebert has an actionscript wiki with lots of useful optimisation techniques.
Nicolas Cannasse is the brilliant mind behind MTASC and Haxe and his blog is great for tips on how the flash virtual machines work, what actionscript gets turned into and indeed on optimising that code. His blog is worth keeping an eye on for articles such as:
Haxe is also worth a look, as it gives you access to the op codes that Alchemy uses for performance gains and has some really nice features.
Mario Klingemann is a great source of ideas when it comes to boosting performance and applies them to some really interesting flash output. I found this article on optimising a seam carving technique very useful as are his conference presentations – slides from past events.
Ryan Christensen at Drawlogic does a good job of explaining number weirdness in flash and also has a recent list of optimisation links.
Optimisation will make your code close to unreadable. Do not optimise prematurely. The job is probably best done by a compiler or a pre/post-processor. Unfortunately, the flash compiler does very little to optimise code. Haxe can do this job and as3c is another option.
Thanks go to those developers who came up with these techniques. I’m sure there’s more to add and I will probably come back to this subject in a later post but, in the meantime, are there any tips that you’d like to share? If the answer is yes then please leave a comment.