Skip to content

Instantly share code, notes, and snippets.

@krizajb
Last active July 19, 2019 13:35
Show Gist options
  • Save krizajb/8fb2aacc68939d8b3dd3f7a1e2a3565b to your computer and use it in GitHub Desktop.
Save krizajb/8fb2aacc68939d8b3dd3f7a1e2a3565b to your computer and use it in GitHub Desktop.
Messure text/string in textfield
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment