The Right Way to Check An Object’s Type

Tags: , , , , ,

There are lots of ways to check the type of an object in AS3. These include the is operator, the deprecated instanceof operator, the constructor field, and a combination of getQualifiedClassName and getDefinitionByName. Which is fastest, cleanest, and most effective? Today’s article puts them all to the test to find out!

Read the rest of this article »

4 Comments

Custom AS3 Annotations

Tags: , , ,

You’ve probably seen built-in metadata tags like [SWF] and [Embed], but have you ever wondered how you could add your very own, custom tags? Today’s article shows you how to add custom annotations to your AS3 classes and methods. Mark old methods of your library with [Deprecated], file format classes with [Version], or anything else you’d like. Today’s article shows you how.

Read the rest of this article »

2 Comments

Get More out of Four Bytes than a Boolean

Tags: , , ,

A Boolean in AS3 takes up four bytes of memory to store a single bit of information. It takes up 32x more memory than it needs. We can make better use of this memory and today’s article explains how.

Read the rest of this article »

2 Comments

When getSize() Lies

Tags: , , , , , , , , , , , ,

flash.sampler.getSize() is a handy tool for figuring out how much memory a class instance uses. However, it is often flat-out wrong. Today’s article tries it out on a variety of classes to find out which ones it works on and which ones it doesn’t.

Read the rest of this article »

4 Comments

How Big Is That Class?

Tags: , , , , , , , ,

When you instantiate one of your classes, how much memory does it use? Today’s article tries out a lot of combinations and counts the bytes used. The conclusion is easy to remember and will give you a solid understanding of how much memory your app is using.

Read the rest of this article »

5 Comments

The Goto Keyword

AS3 has a controversial new keyword: goto. It’s not documented, but this article will tell you how it works. It’ll also talk about why you might want to use it to improve performance or even make your code more readable (gasp!).

Read the rest of this article »

1 Comment

The Cost of If-Else

Tags: , ,

The if-else keyword is not free. So, how expensive is it? Today’s article finds out.

Read the rest of this article »

6 Comments

Bytecode Analysis: Why do-while Is so Slow

Tags: , , , ,

The do-while loop is slower than the for and while loops… at least in Flash. Why? Today’s article digs into the bytecode the compiler generates for a variety of these loops to find out why.

Read the rest of this article »

10 Comments

Saving Memory with BitmapData Tricks

Tags: , , , , ,

Last week’s article showed a variety of tricks for saving memory with ByteArray. Today’s article explores some tricks to use with BitmapData to save even more memory.

Read the rest of this article »

2 Comments

ByteArray Secrets

Tags: , , , ,

The ByteArray class is not as straightforward as you might think. In certain situations, it has surprising, undocumented functionality. Today’s article goes into some of these strange behaviors so you’ll get a better handle on exactly what’s going on behind the scenes.

Read the rest of this article »

6 Comments