http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Vector.html

 In addition to the data type restriction, the Vector class has other restrictions that distinguish it from the Array class:

- A Vector is a dense array. Unlike an Array, which may have values in indices 0 and 7 even if there are no values in positions 1 through 6, a Vector must have a value (or null) in each index.
- A Vector can optionally be fixed-length, meaning the number of elements it contains can't change.
- Access to a Vector's elements is bounds-checked. You can never read a value from an index greater than the final element (length - 1). You can never set a value with an index more than one beyond the current final index (in other words, you can only set a value at an existing index or at index [length]).

As a result of its restrictions, a Vector has two primary benefits over an Array instance whose elements are all instances of a single class:

- Performance: array element access and iteration are much faster when using a Vector instance than when using an Array.
- Type safety: in strict mode the compiler can identify data type errors such as assigning a value of the incorrect data type to a Vector or expecting the wrong data type when reading a value from a Vector. Note, however, that when using thepush() method or unshift() method to add values to a Vector, the arguments' data types are not checked at compile time but are checked at run time.

플래시10(CS4) 에서 새로 생겨난 배열클래스!

Vector는 기존의 범용적인 Array 클래스와는 다르게 저장갯수와 형태를 정의할 수 있다.
때문에 데이터 접근 성능향상과 데이터 타입에 대한 에러를 쉽게 찾을 수 있다.
사용 방법은 생성자를 제외하고 Array와 같다 .

new Vector.<데이터형:data type>(데이터 갯수:int, 갯수를 고정시킬지 결정:Boolean)

var txtVector:Vector.<String> = new Vector.<String>(5);
trace(txtVector);
//null,null,null,null,null
//저장소 갯수가 정해진 경우, 데이터는 꼭 갖고 있게 된다. 문자는 null, 숫자는 0

var pnX:Vector = new Vector.<Number>(10,true);
trace(pnX);
//0,0,0,0,0,0,0,0,0,0,0




저작자 표시 비영리 변경 금지