Created
April 28, 2012 04:54
-
-
Save lynxerzhang/2516117 to your computer and use it in GitHub Desktop.
Bit101's Text Component is Unable set the TextFormat?
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
//I use Bit101's Component framework(Window, Text, PushButton) to create a Alert Component | |
/** | |
* create a window and set size (this window couldn't be drag) | |
*/ | |
var alert:Window = new Window(this, 0, 0, "Alert"); | |
alert.draggable = false; | |
alert.setSize(300, 200); | |
/* | |
* set text to show the alert's info | |
*/ | |
var t:Text = new Text(alert, 0, 0, "Bit101 component"); | |
t.selectable = false; | |
t.editable = false; | |
t.width = alert.width; | |
t.height = alert.height - 60; | |
var format:TextFormat = t.textField.getTextFormat(); | |
format.align = TextFormatAlign.CENTER; | |
format.size = 12; //set the size is 12 | |
format.bold = true;//set the font is bold | |
/** | |
* we found only 'align' set is work, the 'bold' and 'size' not work | |
* | |
* because 't.textField.getTextFormat() return a textformat | |
* that doesn't same as Text Component's internal TextFormat | |
* | |
* and the Component redrawn on the next frame, the 'size' set and 'bold' set will be reset | |
*/ | |
t.textField.defaultTextFormat = format; | |
t.textField.setTextFormat(format); | |
/** | |
* create a button position it | |
*/ | |
var ok:PushButton = new PushButton(alert, 0, 0, "ok"); | |
ok.x = (alert.width - ok.width) * .5; | |
ok.y = (alert.height - ok.height) - ok.height - 10; | |
/** | |
* reposition window | |
*/ | |
alert.x = (stage.stageWidth - alert.width) * .5; | |
alert.y = (stage.stageHeight - alert.height) * .5; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment