Recursion is a commonly-used feature of many programming languages, including AS3. It’s useful for everything from trivial examples like computing the Fibonacci sequence all the way up to advanced sorting techniques like Quicksort and tree algorithms. This article is a first in a series all about recursion. Today we’ll see what kinds of limits the Flash Player puts on us as recursion-using AS3 developers.
Posts Tagged errors
There are three main ways to access the contents of objects in AS3: the dot (
.) operator, the index (
) operator, and the
in operator. The first two are well known and functionally-equivalent because
obj.property evaluates to the same value as
in operator is different as I’ve described before: it returns a
Boolean indicating whether or not the object has the given property. There are a lot of cases—error checking, for example—where we only care if an object has a property and not what that property is. So, can we improve performance by using the
is operator rather than the index or dot operators? (UPDATE: hasOwnProperty results added)
Try/catch blocks are certainly a nice feature to have. They allow you to catch errors that are beyond your control and handle them in a nice manner. They also allow you to throw your own errors and handle them in the same way. This would all be great if it weren’t for the fact that they are tremendously slow. Read on for some surprising test results.