public static function cutTextWidth(tf:FlxText, maxWidth:Float = -1, dotDotDot:Bool = false):Void { maxWidth = maxWidth > 0 ? maxWidth : tf.fieldWidth; if (tf.textField.textWidth+5 > maxWidth) { var copy:String = tf.textField.text; var initialCopy:String = copy; while (tf.textField.textWidth + 5 > maxWidth && copy.length > 0) { copy = copy.substr(0, copy.length - 1); tf.textField.text = dotDotDot ? copy + "..." : copy; } if (initialCopy != copy) tf.dirty = true; } }