Tuesday, April 30, 2013

Flash TextField.textHeight only returns Zero.

I was doing some Flash development this afternoon and ran into an issue with TextFields...

I was creating a dynamic textfield and needed to retreive the field's height after the text was set. No matter what I did, the textHeight property was always Zero.

Finally, I discovered the problem: I had set the textfield.embedFonts=true BUT I HAD FORGOTTEN TO ACTUALLY EMBED THE FONT. (actually I did on the dev version, but not on my test file which is where I was noticing this issue.)

I don't know whether Flash was able to fall back to a default font or if it was because my test file didn't actually display my text field (only builds it and checks its size), but I never received any errors to help point me to the source of this issue.

Once I added the correct font to the Fla's library, I began getting correct values for TextField.textHeight.

It was a silly error, but none of the other formus I read mentioned it.

No comments: