I'm trying to make a dynamic table. First I thought about using Matrix class but then decided to use a1 a2 a3 and so on for the cell names.
I want to increment the string.
This doesn't work. Can anyone help me?Code:var letter:String="a";
letter++;
Printable View
I'm trying to make a dynamic table. First I thought about using Matrix class but then decided to use a1 a2 a3 and so on for the cell names.
I want to increment the string.
This doesn't work. Can anyone help me?Code:var letter:String="a";
letter++;
Ok, I found a solution, I'm using array.
Not that it matters since you found a way, but nothing about that made any sense.
What would a Matrix have to do with a table? What does it mean to increment a String? And what was your solution with array to what actual problem?
If by "increment a string" you mean "increment a character stored in a string to the character with the next higher charCode", you could do it like this:
Note that Strings are immutable, so getNextLetter returns a NEW String with the desired value. Note also that if you pass it a String with more or less than 1 character, you get nonsense output, or an error.Code:var letter:String = "a";
function getNextLetter(input:String):String{
return String.fromCharCode(input.charCodeAt(0)+1));
}
letter = getNextLetter(letter);
That was exactly what I was looking for. Thanks a lot.