The Array class has a great function: sortOn(). It does a fast sort based on a property of each element of the array. Unfortunately, there is no equivalent in the Vector class. Below are some attempts to get around that limitation and preserve as much of the speed of sortOn() as possible.
Posts Tagged vector
Adding on to existing arrays and vectors is one of those really common tasks that sounds dreary. Everyone knows about push() and unshift() for single elements and concat() for lots of elements. But what if you want to add a lot of elements to an existing array or vector without allocating a new array or vector? I have the solution.
The chief quality of Vectors is that they hold a single type of object. This is why they are sometimes called “typed arrays”. So what would happen if you wanted to convert an array of mixed-type objects into a vector?
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.
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.
Vectors– typed arrays in AS3– are much quicker than arrays and therefore very useful. There are many times where you end up with arrays though and need to convert them into vectors for the bulk of your using that data. This article is about that process.
There are many ways to clear an Array or Vector. I’m tired of seeing the foolish ones. Read this and make sure you’re not doing anything foolish:
I really want to like Vectors, the new typed array functionality in Flash 10. In fact, I use it as often as I can. But there are some really awkward things about it that make it a pain. Here are some gotchas: