From 3f54473d60817ea7971071050ae8bdc3b57e8ba2 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Sun, 21 Oct 2007 21:35:25 +0000 Subject: [PATCH] Accept a text format to use, so the button can match the UI it appears in. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@307 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/SimpleTextButton.as | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/as/com/threerings/flash/SimpleTextButton.as b/src/as/com/threerings/flash/SimpleTextButton.as index bc065856..effc344f 100644 --- a/src/as/com/threerings/flash/SimpleTextButton.as +++ b/src/as/com/threerings/flash/SimpleTextButton.as @@ -27,6 +27,7 @@ import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFieldAutoSize; +import flash.text.TextFormat; /** * Displays a simple button with a rounded rectangle or rectangle for a face. @@ -35,21 +36,26 @@ public class SimpleTextButton extends SimpleButton { public function SimpleTextButton ( text :String, rounded :Boolean = true, foreground :uint = 0x003366, - background :uint = 0x6699CC, highlight :uint = 0x0066FF, padding :int = 5) + background :uint = 0x6699CC, highlight :uint = 0x0066FF, padding :int = 5, + textFormat :TextFormat = null) { - upState = makeFace(text, rounded, foreground, background, padding); - overState = makeFace(text, rounded, highlight, background, padding); - downState = makeFace(text, rounded, background, highlight, padding); + upState = makeFace(text, rounded, foreground, background, padding, textFormat); + overState = makeFace(text, rounded, highlight, background, padding, textFormat); + downState = makeFace(text, rounded, background, highlight, padding, textFormat); hitTestState = upState; } protected function makeFace ( - text :String, rounded :Boolean, foreground :uint, background :uint, padding :int) :Sprite + text :String, rounded :Boolean, foreground :uint, background :uint, + padding :int, textFormat :TextFormat) :Sprite { var face :Sprite = new Sprite(); // create the label so that we can measure its size var label :TextField = new TextField(); + if (textFormat) { + label.defaultTextFormat = textFormat; + } label.text = text; label.textColor = foreground; label.autoSize = TextFieldAutoSize.LEFT;