Posts Tagged operator

Dynamic Access: Part 1 (Indexing Arrays and Vectors)

Tags: , , ,

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.

Read the rest of this article »

1 Comment

Comparing Objects

Tags: , ,

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.

Read the rest of this article »

5 Comments

Indexing Anything

Tags: ,

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.

Read the rest of this article »

1 Comment

Pointless Code

Tags: , ,

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:

Read the rest of this article »

7 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

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

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

Everything’s a Function

Tags:

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

No Comments

The Magic of is

Tags:

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

4 Comments

Fancy Or

Tags: ,

The lowly || operator in the hands of AS3 and JavaScript is not so lowly. Here’s a quick time saver.

Read the rest of this article »

4 Comments