Skip to content

Instantly share code, notes, and snippets.

@krizajb
krizajb / measureString.as
Last active Jul 19, 2019
Messure text/string in textfield
View measureString.as
public static function measureString(str:String, format:TextFormat) : Number {
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT; // adjust appropriately
textField.defaultTextFormat = format;
textField.text = str;
return textField.textWidth;
}