The Flash API has a gem of a class in Proxy. You can use it to customize the behavior of the dot (.), index ([]), delete, and in operators as well as the for-in and for-each-in loops. Today’s article answers a recent comment by exploring the performance implications of all this fancy customizing that Proxy allows.
Posts Tagged in
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 obj["property"]. The 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)