Archive for June, 2009

Details of NaN

The constant NaN (not a number) can come up in a lot of situations. In AS3 it’s the default value of a Number field, it’s the result of division by zero in AS2, AS3, and JavaScript, and you can get it in a number of other ways. This article is about the reality of dealing with NaN.

Read the rest of this entry »

Tags:

2 Comments

Uses for arguments

The arguments magic variable has been around since the AS2 days. It used to be more useful than it is in AS3, but don’t overlook it completely!

Read the rest of this entry »

Tags:

2 Comments

Clearing an Array or Vector

There are many ways to clear an Array or Vector. I’m tired of seeing the foolish ones. Read this and make sure you’re not doing anything foolish:

Read the rest of this entry »

Tags: ,

5 Comments

Two Kinds of Casts

AS3 has two ways you can typecast a variable. These ways are not equivalent. Let’s take a look at how they differ:

Read the rest of this entry »

Tags:

6 Comments

Everything’s a Function

The function call operator () is one of the most straightforward, well-understood, and universal operators in all of programming. Let’s see how AS3 can butcher it:

Read the rest of this entry »

Tags:

No Comments

Details of toString()

When an object is converted to a String, it is first checked for a toString() method. But there are subtleties to this that you may not have considered.

Read the rest of this entry »

Tags:

No Comments

The Type-Safety of Vectors

I really want to like Vectors, the new typed array functionality in Flash 10. In fact, I use it as often as I can. But there are some really awkward things about it that make it a pain. Here are some gotchas:

Read the rest of this entry »

Tags:

3 Comments

Spot The Problem

You could probably do this in most languages and it might be hard to spot. See for yourself.

Read the rest of this entry »

Tags: ,

2 Comments

Null and Undefined

Usually languages just have one way to specify “no value”. Call it null or nil or whatever you’d like, but AS3 and JavaScript have two: null and undefined. Here’s a little bit to help you understand when and why you’ll come across the two as well as some tricky differences between them.

Read the rest of this entry »

Tags:

1 Comment

The Magic of is

By now you’ve certainly heard of the is operator in AS3. It’s the replacement for instanceof in AS2. But the two are not the same! Don’t make this mistake…

Read the rest of this entry »

Tags:

4 Comments