From 284a4070ea94e1810680bec09d7a7d86b8c61bfc Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 12 Jun 2008 20:10:41 +0000 Subject: [PATCH] Added updateText(). git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@540 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/TextFieldUtil.as | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/as/com/threerings/flash/TextFieldUtil.as b/src/as/com/threerings/flash/TextFieldUtil.as index 81c70aa8..2acf6dea 100644 --- a/src/as/com/threerings/flash/TextFieldUtil.as +++ b/src/as/com/threerings/flash/TextFieldUtil.as @@ -67,11 +67,7 @@ public class TextFieldUtil if (formatProps != null) { tf.defaultTextFormat = createFormat(formatProps); } - tf.text = text; - if (tf.autoSize != TextFieldAutoSize.NONE) { - tf.width = tf.textWidth + WIDTH_PAD; - tf.height = tf.textHeight + HEIGHT_PAD; - } + updateText(tf, text); return tf; } @@ -97,7 +93,19 @@ public class TextFieldUtil var f :TextFormat = field.defaultTextFormat; // this gets a clone of the default fmt Util.init(f, props); // update the clone field.defaultTextFormat = f; // set it as the new default - field.text = field.text; // jiggle the text to update it + updateText(field, field.text); // jiggle the text to update it + } + + /** + * Update the text in the field, automatically resizing it if appropriate. + */ + public static function updateText (field :TextField, text :String) :void + { + field.text = text; + if (field.autoSize != TextFieldAutoSize.NONE) { + field.width = field.textWidth + WIDTH_PAD; + field.height = field.textHeight + HEIGHT_PAD; + } } /**