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.
Archive for category AS3
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.
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.
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.
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.
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.
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.
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!
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:
AS3 has two ways you can typecast a variable. These ways are not equivalent. Let’s take a look at how they differ: