Rony For example- the Array.length is 10. and i ask for Array[40], even there is no 40 the debugger is not dropping any errors and the app just skip the next code lines.
This is actually the proper behavior. Arrays can be populated at any index, and parts of them can be empty. If you try to access an index that is not populated, including beyond the length, it simply returns undefined
. No errors.
var arr:Array = ["hi"];
trace(arr[123]); // console: undefined
If you want more strictness, you can use Vector
instead. It's a typed array class, and it includes range checks. You can even set a fixed
length to get better performance when an array will never resize.
var arr:Vector.<String> = new <String>["hi"];
trace(arr[123]); // RangeError: Error #1125: The index 123 is out of range 1.