Học Actionscript 3.0 - p 7

Vectors a database had three records, it would be equivalent to one array of three arrays. Creating this arrangement is as simple as using an inner array as a value for one of the indices of the outer array. You can do this at the outset, or add it using push()—both of which are demonstrated here: var mdArray1:Array = ["a", "b", ["c", "d"]]; var mdArray2:Array = ["e", "f"]; (["g", "h"]); To access values in a multidimensional array, you must use multiple brackets to go into the nested arrays. For instance, continuing the prior example to retrieve the first item in the array mdArray1, you need only the standard single bracket syntax: trace(mdArray1[0]); //traces "a" to the Output panel However, to access. | Vectors a database had three records it would be equivalent to one array of three arrays. Creating this arrangement is as simple as using an inner array as a value for one of the indices of the outer array You can do this at the outset or add it using push both of which are demonstrated here var mdArray1 Array a b c d var mdArray2 Array e f g h To access values in a multidimensional array you must use multiple brackets to go into the nested arrays. For instance continuing the prior example to retrieve the first item in the array mdArray1 you need only the standard single bracket syntax trace mdArray1 0 traces a to the Output panel However to access the values in the nested array requires two components. First you must identify the nested array as the third item of mdArray1 at index 2 . Then you must reference the item within that nested array with another pair of brackets. So to retrieve c which is the first item in the nested array the syntax is as follows trace mdArray1 2 0 traces c to the Output panel This makes sense if you think about it in steps because not only is mdArray1 an array requiring bracket syntax to retrieve an item therein but mdArray1 2 is also an array requiring its own brackets to retrieve an item. NOTE There is another kind of array called an associative array which is often used interchangeably with custom objects. We ll discuss both in the Custom Objects section later in this chapter. Vectors Vectors not to be confused with the precise lines curves and shapes created by such object-drawing tools as Adobe Illustrator are typed arrays. Arrays like those in the previous section can contain data of any type. The following example array includes a String Number and Boolean var arr Array new Array arr 0 avocado arr o 2 arr 0 true A vector however can contain data of only one type which is determined at the time the vector was created. Although vector syntax may look a little odd at first its principle uniqueness is the addition of .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
2    74    2    03-06-2024
11    70    2    03-06-2024
50    672    1    03-06-2024
55    76    2    03-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.