MXMLC’s -define feature allows you to do two things: compile-time constants (as covered previously) and conditional compilation. Both are very useful, so today I’m covering conditional compilation.
Archive for November, 2009
For Vs. While
Nov 27
I’ve recently been seeing more and more usage of while loops by those who I presume are interested in performance. I’ve always assumed that these was not faster than for loops, but today I am finding out.
BitmapData Alpha Performance
Nov 25
The BitmapData class is among the most useful classes in AS3. When it was introduced in Flash 8 it dramatically improved Flash development by opening up new potential for features and optimization. Since it’s used so often, it’s good to know as much about it as possible. Today I’m going to cover the performance difference that turning alpha (a.k.a. transparency) on makes.
Map Performance
Nov 23
I recently received an e-mail from Dmitry Zhelnin (translation) with a test he did concerning the speed of a couple ways to get a value for a key, which I like to call a map and Wikipedia likes to call an associative array. I’d been meaning to do a similar test for a while now and, guess what, I finally have! UPDATE: fixed miss test for fixed-size Vectors.
Compile-Time Constants
Nov 18
Alec McEachran’s latest article about constants reminded me of a trick I’ve recently learned and became a big fan of. His article expresses the pain endured by those who wish for both speed and maintainability in their AS3 apps. The solution the article doesn’t reach though is that of compile-time constants. This is truly the best of both worlds, so let’s learn about it.
LocalConnection Speed
Nov 16
For a variety of reasons, you may need to communicate between two Flash Player instances. You may do this to implement debug logging, communicate with a mini game, or coordinate between a main SWF and an advertisement SWF. So, what kind of speed can you expect? This article will show you.
Inlining Math Functions
Nov 13
As a followup to my article on Inlining Math.ceil(), I decided to inline some more functions in the Math class. Read on for the code as well as tests proving correctness and speed.
Faster isNaN()
Nov 11
You cannot directly check if a value is NaN by comparing with it. AS3, AS2, and JavaScript therefore provide a useful isNaN() function to do this very check. However, it is very slow. Today I’ll show you a workaround that results in a faster isNaN(): (UPDATE: see the definitive article on isNaN for much more!)
Var Args Is Slow
Nov 9
Var args (a.k.a. …rest) is a useful feature introduced in AS3. Previously in AS2 (and JavaScript still), we were forced to pass an Array of arguments where an unlimited-length argument list would have been much natural. Unfortunately, this can be really slow. In this article I’ll show a much quicker way to pass unlimited arguments to functions.