Last active
July 19, 2019 13:35
-
-
Save krizajb/8fb2aacc68939d8b3dd3f7a1e2a3565b to your computer and use it in GitHub Desktop.
Messure text/string in textfield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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