Archive for category AS2

Definitive isNaN()

I wrote an article in November 2009 titled Faster isNaN() and a followup to it titled Even Faster isNaN() and continue to get comments on both, so today I’m doing a followup to bring together both articles and the many comments on them into one definitive article. (UPDATE: added Windows performance results)

Read the rest of this entry »

Tags: , , ,

10 Comments

Function Length

In my last article on getProperties, there was one strange finding in the tests of standard classes: the Function class seems to have a length field. What is it? Today we’ll see

Read the rest of this entry »

Tags: , , , , , , ,

4 Comments

Argument Clash

I am often burned by MXMLC: the AS3 compiler. When I am, I find this infuriating and look for the reason why this happened. Today I’ll tip you off about this problem and delve into what it means if you happen to trigger it.

Read the rest of this entry »

Tags: , , , , ,

No Comments

Cancelable Function

I recently had the need to cancel a callback function that I had passed to an API. The API had taken my callback function directly, so there was no way to remove the event listener. So I thought back to an old article I wrote and came up with a solution. Read on for a utility function that will allow you to cancel function callback in AS3 as well as JavaScript and AS2.

Read the rest of this entry »

Tags: , , ,

7 Comments

Another Gotcha

I’m back from a month off for winter break! Today I’ll start off with a very short article to ease back into things. Today I’ll cover a “gotcha” that got me recently and resulted in a bug report that was pretty tough to solve. Read on to see what it was.

Read the rest of this entry »

Tags: , ,

2 Comments

For Vs. While

I’ve recently been seeing more and more usage of while loops by those who I presume are interested in performance. I’ve always assumed that these was not faster than for loops, but today I am finding out.

Read the rest of this entry »

Tags: , , ,

12 Comments

Faster isNaN()

You cannot directly check if a value is NaN by comparing with it. AS3, AS2, and JavaScript therefore provide a useful isNaN() function to do this very check. However, it is very slow. Today I’ll show you a workaround that results in a faster isNaN(): (UPDATE: see the definitive article on isNaN for much more!)

Read the rest of this entry »

Tags: ,

21 Comments

Flexible If Syntax

This article is sort of a follow-up to my article on Flexible Loop Syntax. This was reported to my by a coworker who spotted the anomaly. I guess he had done with if the same sort of thing that I had done with for. Read on for a little insight into how the comma operator interacts with the if statement.

Read the rest of this entry »

Tags: , , , ,

5 Comments

Repeatable Random

Everybody knows about Math.random(), and for good reason. It’s pretty much the way to get random numbers in AS3, AS2, and JavaScript other than bizarre alternatives like AS3′s BitmapData.noise(). However, it has one critical problem that arises when you want to repeat a certain test or prevent game cheaters from exploiting the randomizer until they get an “easy” setup or desirable outcome. This problem is the lack of repeatability.

Read the rest of this entry »

Tags:

10 Comments

Inline Math.ceil()

Math.ceil() is a common, mundane function that you likely call all the time. I know I do. If performance gets to be important and you have a Math.ceil() in some inner loop or frequently called function, consider inlining it. Below I’ll show you how and provide a test app showing you just how much CPU time you’ll save.

Read the rest of this entry »

Tags: , ,

11 Comments