Vectors are a new addition to ActionScript 3.0 for Flash Player 10 and later. They can help you write fast, efficient, and concise code where you would otherwise use an array.
A Vector is an optimized kind of
Array that is made to store and retrieve instances of the same class. It behaves almost identically to an
Array, but the key difference is that it stores only one type of object, as you can see in Figure 9-1.
In the original
Array, you can store all kinds of objects together. In a
Vector, you store only one kind. In the preceding example, the
Vector only stores instances of
Shoe. In this chapter, you'll see when and why this can be useful. I'll also cover the other minor differences between the two data types.
FP10. Vector is available when compiling SWFs for Flash Player 10 and above.
Vectors are only available on Flash Player 10 and up. If you're reading this book sequentially, this is the first time you will have seen a whole class that is only available in certain versions of Flash Player.
Figure 9.1. An Array and a Vector compared
Before I examine the when, why, and how of using Vectors, I'll take a moment to answer the next question:
In many ways, ActionScript has been evolving backward, from a "modern" dynamically typed, high-level, object-oriented language toward a statically typed language ...