Today’s article is a followup to an article (Cast Speed, itself a followup to Two Types of Casts) from September that continues to gather comments. Sharp-eyed reader fastas3 brought up a good point that warranted some further investigation into the topic. So today we’ll be taking yet-another look at typecasting in AS3 to try to unravel some of its strange mysteries.
Posts Tagged performance
I’ve talked about var args, the arguments keyword, and even the length of a function that has default arguments, but I’ve never written an article all about default arguments… until today.
Today I’m revisiting an article I wrote last August about conditionals: if-else
chains, ternary (? :
) operators, and switch
statements. In that article I showed that if-else
chains are about as fast as ternary operators and that both of them are 10-15% faster than switch
statements. Today we’ll take a look at how those conditionals scale beyond just the few cases in the last article.
I wrote an article last November titled For Vs. While that needs a bit of updating an expanding today. While I updated the performance figures in my series on Flash 10.1 performance, I continue to get questions in the comments section of the original article that explore new areas. So today we’ll look at the ubiquitous for
and while
loops a little more.
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)
I’ve talked before about explicit type conversion and used the function-call style (Type(obj)
) and the as
keyword to accomplish the task. Today, I’m going to talk about implicit type conversion and use—as implicit would imply—no operators at all!
There are actually three ways to call a function in AS3. Can you name all three? Do you know which is fastest? Does the type of function being called matter? Today I’ll tackle these questions and find some surprising facts about the three ways to call a function in AS3.
Amazingly, I’ve never covered the const
keyword, but a couple of recent comments have prompted me to cover the subject in depth with today’s article.
I recently received an e-mail from asking which is faster: a DisplayObjectContainer
or a Vector
of DisplayObject
. To ask this is to question whether or not we can do better than the Flash Player’s native container of DisplayObjects
using AS3. It turns out that we can. Read on for several ways to improve on DisplayObjectContainer
‘s speed.
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)