Hi there… This is my first question here and I have a feeling it’ll be very stupid, but I really can’t find the solution myself. :diss:
I have a code here:
//Displays alphabet letter by letter in a specified area
var q:Number = 0; //This should be the counter
//Two for loops used to create grid for letters
for (var i:uint = 0; i < alphabetString.length/ratio; i++)
{
for (var j:uint = 0; j < ratio; j++)
{
var letter:Letter; //Letter is customized TextField... nothing extraordinary in this part of code
var o:uint; //I've created "o" to test, whether accessing the outside variable causes the problem
o = q;
var letterName:uint = alphabetString.charCodeAt(q); // This was created as another workaround to test the cause of the problem. "alphabetString" is just a String with all the letters in my alphabet.
// And now "alphabetDictionary" contains the "Letters" named by their char code.
letter = alphabetDictionary[alphabetString.charCodeAt(o)]; //Apparently no Letter has been assigned to letter ...
letter.format = format; // ..cause these three methods are addressing null.
letter.updateStyle();
letter.setCenter(letterArea.width / (alphabetString.length / ratio) * i, letterArea.height / ratio * j);
// The funny thing is, that q, o and letterName can be easily traced so they all exists inside the loop.
trace ("Letter number " + q + " is at the possition " + letter.x, letter.y, ". The letter's value is " + letter.text);
// Here I'm just changing the name and adding the letter to the display stack
letter.name = String(alphabetString.charCodeAt(o));
this.addChild(letter);
q++; //And incrementing the counter
}
}
Well, funny thing is, that if I’m addressing the “Letter” in “alphabetDictionary” (via this alphabetString.charCodeAt(o)) while using one (or both) of the loop counters instead of q or o it works fine (well not as intended of course, but it is assigning the "Letter"s with no problem). And I really don’t get it…
Switching bettwen Number, int and uint for the var type doesn’t do anything.
I’m really out of ideas here… if anyone have some, please help. :puzzle: