Many classes in AS3 are dynamic, meaning that you can add and remove their fields at runtime. This is powerful, but extraordinarily slow. This series will cover some common ways you might be inadvertently using dynamic access or using it too much. This will help you make your code faster. In the first installation of the series, I’m going to talk about the simple act of indexing an array or vector.
Posts Tagged operator
The comparison operators (<, <=, ==, >=, >) are clearly core to any programming language. The AS3 docs tell us a little about AS3’s special handling of strings when compared, but there is more to the story.
Indexing is a little bit special in ECMAScript languages like AS3, AS2, and JavaScript. MXMLC will gleefully let you index just about anything, even if there isn’t a chance it’ll work.
We’ve all seen it, perhaps even in our own code. It’s something I think we do because we’re not really sure what would happen if we didn’t do it. Here are some little tidbits of pointless code I’ve been seeing recently:
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 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.
AS3 has two ways you can typecast a variable. These ways are not equivalent. Let’s take a look at how they differ:
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:
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…
The lowly || operator in the hands of AS3 and JavaScript is not so lowly. Here’s a quick time saver.