Archive for category AS3

Super Is (Really) Optional!

Tags: ,

Like Java, AS3 has a super() function you can call from your constructor to call your parent class’ constructor. As it turns out, this is more optional than you might think.

Read the rest of this article »

7 Comments

Loop Safety

Tags:

This is a curiosity I’ve had for far too long. Why didn’t I make these simple tests years ago when I was first learning AS3? I’m not sure, but judging by a lot of other people’s AS3 that I’ve read, many people don’t seem to understand it.

Read the rest of this article »

4 Comments

The in Operator

Tags:

I was recently surprised to find that the in keyword in AS3 has two meanings. I had been using it as part of the for-in and for-each loop syntax for a long time. Turns out it is an operator of its own. Read on for details.

Read the rest of this article »

2 Comments

Messing With Iterators

Tags:

The for-in and for-each loops are convenient and likely to be the loops you use most. For this reason alone you should make sure you know what you can and can’t do with them. Here’s one thing I just found can save me some typing and some bloat.

Read the rest of this article »

2 Comments

A Little Import Bug

Tags:

This is ridiculous. I don’t know its purpose. Perhaps it’s even a bug in MXMLC. But I did it nonetheless and was confused for a good while. Here’s a quick little bug for you to avoid.

Read the rest of this article »

No Comments

Removing Event Listeners

Tags:

Making sure you remove event listeners is good for both correctness and garbage collection. Sometimes you don’t want (or need) to hear events any more and some times you just need to release references to aid the garbage collector in memory cleanup. Whatever your reason, there are a few ways to do it.

Read the rest of this article »

2 Comments

Details of NaN

Tags:

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 article »

2 Comments

Uses for arguments

Tags:

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 article »

2 Comments

Clearing an Array or Vector

Tags: ,

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 article »

5 Comments

Two Kinds of Casts

Tags:

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 article »

6 Comments