Very weird error reading multi-line .txt file

Hello,

sorry to be asking so many questions on the same day, but they are all different and have all got me stunned. This time I’m reading a 2d array from a .txt file, this is what I do:

[Embed(source = '../lib/lvl1front.txt', mimeType = "application/octet-stream")]
private var frontTxt:Class;

Then a bit further:

var fgString:String = new frontTxt();
foreGround = stringToArray(fgString);

The stringToArray function is where things go horribly bad:

private function stringToArray(input:String):Array
{
	var output:Array = new Array();

	var rows:Array = input.split("
");
	for (var i:uint = 0; i < rows.length; i++)
	{
		var row:String = rows* as String;
		var column:Array = row.split(",");
		var newArray:Array = new Array();

		for (var j:uint = 0; j < column.length; j++)
		{
			var data:uint = column[j] as uint;
			newArray.push(column[j]);
		}

		output* = newArray;
	}

	trace(output);
	return output;
}

I get no errors at all so far. But this is what the trace shows:

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,0,0,0,0,0,1,4,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,0,0,1
,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1
,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,1,0,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1

etc.

Notice the starting comma on every line except the first? I think it’s the newline character somehow interfering, but I’ve tried everything I can think of, and nothing has helped. How can I fix this?

  • Maqrkk