0
votes

I'm trying to create a very simple 2d array in ActionScript 3.0

var arr:Array = new Array();

arr[0][0] = "Hello";
arr[0][1] = "Ali";

trace(arr[0][0]);
trace(arr[0][1]);

But below error has comes up :

A term is undefined and has no properties.

Please tell me what am i doing wrong.

2

2 Answers

4
votes

You have to add an extra array for the first dimension:

arr[0] = [];
arr[0][0] = "Hello";
arr[0][1] = "Ali";
2
votes

This line:

 var arr:Array = new Array([3], [3]);

Is creating an array containing two arrays, each of which has one element containing the number 3. That means that when you get to the third iteration multiArr[i] is undefined. This is clearly a misunderstanding of how to define arrays in AS31

SO YOU JUST REFER THIS LINK

Problem with 2d Array in AS3