Using the new Vector Class in place of the Arrays
Vectors are one the new "features" of the Flash Player 10. Unlike the Arrays, they can only keep one type of data. So trying to add a String to a Vector that was initialised to contain only Integers will result in a compile error. The main advantage of using the Vector class is increased performance, as Flash doesn't have to check its content to verify what kind of data is stored there. It also provides a type safety, if you try to store multiple types of data it will give you an error (well, not always as you will see in the article).
The use of the Vectors is pretty much the same as the Arrays but the way of defining a Vector object is a bit unusual to anything I have seen before in ActionScript 3.First you declare the variable to be a type of a Vector and then after that you also add a dot and define something what is called "the Vector's base type" and needs to be wrapped in the angle brackets. This is a type of data you want to use with your Vector and it can be anything including your own classes.
var myVector:Vector.<uint> = new Vector.<uint>();
When your Vector is created you can use it as a standard Array:
var myVector:Vector.<uint> = new Vector.<uint>();
myVector[0] = 10;
myVector.push(20);
trace(myVector[0] + ", " + myVector[1]); //returns 10, 20
trace(myVector.length); //returns 2
You can also specify initial number of elements in the Vector passing a parameter to the constructor or later using a length property. If you also add a "true" to the constructor, your defined length will be fixed so adding more elements than the limit will result in the error.
//Vector with fixed number of two elements
var myVector:Vector.<uint> = new Vector.<uint>(2, true);
myVector[0] = 10;
myVector[1] = 20;
myVector[2] = 30;
//This will give an error: RangeError: Error #1125: The index 2 is out of range 2.
When defining fixed number of elements, you can't use push() method as your vector will have a these elements already created. So new myVector.<uint>(2, true) will create two empty elements and myVector.length will return 2. For that reason a compile error will be return: "RangeError: Error #1126: Cannot change the length of a fixed Vector" as the push() method adds a new element to the end of a vector so Flash won't be able to add a third element to a vector with a length limit 2 and 2 elements already created.
Also trying to add anything else than the defined "base type" will return an error:
var myVector:Vector.<uint> = new Vector.<uint>(2);
myVector[0] = 10;
myVector[1] = "hello"; //this is not uint
//This will gine an error: 1067: Implicit coercion of a value of
//type String to an unrelated type uint.
But if you try to add an integer value to unassigned integer type Vector...
var myVector:Vector.<uint> = new Vector.<uint>( );
myVector[0] = 10;
myVector[1] = -20; //this is not an uint!
trace(myVector[0] + ", " + myVector[1]); //returns 10, 4294967276
trace(myVector.length); //returns 2
...it won't give you any type of error but myVector[1] will not hold a proper value. I would expect at least a warning as if you would try to add a negative value to the uint variable: "Warning: 1092: Negative value used where a uint (non-negative) value is expected". And the value of 4294967276 is basically a result of Sum of uint.MAX_VALUE and the negative integer -20. So you need to be careful and do not count only on the "type safety".

