I'm trying to understand how this piece of code from Keith Peter's Advanced Actionscript works. Essentially there's a for loop going on to split key/value pairs seperated by :. Here's the code:
var definition:Object = new Object();
for(var i = 0;i < tokens.length; i++)
{
var key:String = tokens[i].split(":")[0];
var val:String = tokens[i].split(":")[1];
definition[key] = val;
}
And tokens is an array of strings containing values such as:
["type:GraphicTile", "graphicClass:MapTest_Tile01"]
The thing I can't understand is, what is the significence of "[0]" and "[1]". How does [1] indicate that the String val is to hold the data after the ":" split(the value, like "GraphicTile" or "MapTest_Tile01"), and [0] pointing to the data before the split(keys like "type" or "graphicClass"). Adobe's Actionscript reference doesn't list any parameters that can be passed to the Array.split method using square brackets like this.