Archive for November, 2009

Conditional Compilation

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.

Read the rest of this entry »

Tags: , ,

10 Comments

For Vs. While

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.

Read the rest of this entry »

Tags: , , ,

12 Comments

BitmapData Alpha Performance

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.

Read the rest of this entry »

Tags: , , ,

4 Comments

Map Performance

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.

Read the rest of this entry »

Tags: , , , , , , ,

13 Comments

Put In Frame

For a change, today’s article has nothing to do with performance. Instead, I’m going to tackle a simple task that I find myself doing all the time while working with Flash UIs: displaying icons. It sounds boring and, well, it really aught to be. However, I’m constantly asked by UI designers to populate some list item clips, frames, other other little holders with icons that are dynamically loaded by context. I figure that many others must be asked to do the same, so today’s article shows you a little function to help with that task.

Read the rest of this entry »

Tags: , , ,

2 Comments

Compile-Time Constants

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.

Read the rest of this entry »

Tags: , ,

11 Comments

LocalConnection Speed

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.

Read the rest of this entry »

Tags: ,

4 Comments

Inlining Math Functions

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.

Read the rest of this entry »

Tags: , , , ,

3 Comments

Faster isNaN()

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!)

Read the rest of this entry »

Tags: ,

21 Comments

Var Args Is Slow

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.

Read the rest of this entry »

Tags: ,

2 Comments