March 20, 2009Text in Flash is a very special chapter. Static textfields works well, but once you begin to change the text dynamicly at runtime anything could happen. I recently wanted to change the text in a dynamic textfield that was slightly rotated. The text that was entered in the Flash IDE appeared as it should but once changed the textfield dissapeared completely.
After some searching I found a couple of pages that suggested it could be a font embed problem. http://mc-computing.com/languages/ActionScript/Rotating_Text.html has some good info on that. But the problem remained since I used "Anti-alias for readability" and had the font embedded.
Then the solution to an older problem struck me. I had prior had trouble with keeping the font format while changing the text. Appearently things like letter spacing etc is removed once the new text is set. The solution to this is to store away the font format, change the text and then set the font format back. I tested if that could be the case also for rotated text and it was!
var tf:TextFormat = txtHeader.getTextFormat();
txtHeader.text = "MY NEW TEXT";