Problem with System.Array.IndexOf();

I’m trying to translate this AS3 script (from Lynda’s Dlash game development series) to Java:

if(allTiles.indexOf(allTiles[yPos - 1]) != -1  allTiles[yPos -1][xPos] == 0)
{
	allTiles[yPos - 1][xPos] = 1;
	allTiles[yPos][xPos] = 0;
	tile.y -= tileW;
}

to

if (System.Array.IndexOf(allTiles, allTiles[yPos - 1]) != -1  allTiles[yPos - 1][xPos] == 0) {
	allTiles[yPos - 1][xPos] = 1;
	allTiles[yPos][xPos] = 0;
	tile.transform.position.y += 12;
}

I’m not sure which part was wrong, but for some reason, it just kept returning me the error: IndexOutOfRangeException: Array Index is out of range.

I mean, the IndexOf function was suppose to check whether the value is in the Array right? And it should return me with either 0 or -1… instead, it gave me that error.

In case you’re confused, here’s the Array:

var arr : Array = [[1,1,1],[1,0,1],[1,1,1]];

yPos = 0

oh thanks Alexey!!! Thanks for saving me from this 2 weeks of horror!!!

The answer is so simple, and yet it took me so long to go tweak with the IndexOf() thing…

I think indexof may only work with single dimension arrays (note, I’m looking at this from a C# point of view)

well, after two weeks of experimenting with indexOf, I found a few ways you could or could not use indexOf with 2 dimension array… Though it was a pain in the ass for me… I learned a lot from this lesson… Think I can program better from now on…