views:

487

answers:

1

Hi

I'm trying to calculate the textWidth, but it seems to ignore the white spaces at the end. The text

"Hello" "Hello "

returns the same text width. A string with " " returns 0. How do I calculate the width with the space?

A: 

You could always get the length of the string.

text.length

And then multiply that by how wide your characters are.

For example:

var aChar:String = "A";
var textWidth:int = (text.length) * (width of aChar);
Kyra