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
This commit is contained in:
@@ -27,6 +27,7 @@ import flash.display.Sprite;
|
|||||||
|
|
||||||
import flash.text.TextField;
|
import flash.text.TextField;
|
||||||
import flash.text.TextFieldAutoSize;
|
import flash.text.TextFieldAutoSize;
|
||||||
|
import flash.text.TextFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a simple button with a rounded rectangle or rectangle for a face.
|
* 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 (
|
public function SimpleTextButton (
|
||||||
text :String, rounded :Boolean = true, foreground :uint = 0x003366,
|
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);
|
upState = makeFace(text, rounded, foreground, background, padding, textFormat);
|
||||||
overState = makeFace(text, rounded, highlight, background, padding);
|
overState = makeFace(text, rounded, highlight, background, padding, textFormat);
|
||||||
downState = makeFace(text, rounded, background, highlight, padding);
|
downState = makeFace(text, rounded, background, highlight, padding, textFormat);
|
||||||
hitTestState = upState;
|
hitTestState = upState;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeFace (
|
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();
|
var face :Sprite = new Sprite();
|
||||||
|
|
||||||
// create the label so that we can measure its size
|
// create the label so that we can measure its size
|
||||||
var label :TextField = new TextField();
|
var label :TextField = new TextField();
|
||||||
|
if (textFormat) {
|
||||||
|
label.defaultTextFormat = textFormat;
|
||||||
|
}
|
||||||
label.text = text;
|
label.text = text;
|
||||||
label.textColor = foreground;
|
label.textColor = foreground;
|
||||||
label.autoSize = TextFieldAutoSize.LEFT;
|
label.autoSize = TextFieldAutoSize.LEFT;
|
||||||
|
|||||||
Reference in New Issue
Block a user