When positioning text there is easy way to set horizontal align like in this example:
_background = new Sprite();
_background.graphics.beginFill(112233,0.7);
_background.graphics.drawRect(0,0,200,20);
_itemLabel.width = _background.width;
rollOutStyle = _itemLabel.getTextFormat();
rollOutStyle.align = TextFormatAlign.CENTER;
another option is to switch last two lines by:
_itemLabel.autoSize = TextFieldAutoSize.CENTER;
But there is no such solution for vertical. We have to set it manually:
_itemLabel.y = _background.height * 0.5 - _itemLabel.textHeight * 0.5;
_background = new Sprite();
_background.graphics.beginFill(112233,0.7);
_background.graphics.drawRect(0,0,200,20);
_itemLabel.width = _background.width;
rollOutStyle = _itemLabel.getTextFormat();
rollOutStyle.align = TextFormatAlign.CENTER;
another option is to switch last two lines by:
_itemLabel.autoSize = TextFieldAutoSize.CENTER;
But there is no such solution for vertical. We have to set it manually:
_itemLabel.y = _background.height * 0.5 - _itemLabel.textHeight * 0.5;
No comments:
Post a Comment