随着舞台大小的变化,我想改变字体大小。
我有私人var myFormat:TextFormat = new TextFormat();
然后当对象生成时,它会写入下面的
_buttonText.wordWrap = true;
myFormat.size = 15;
myFormat.align = TextFormatAlign.CENTER;
_buttonText.textColor = 0x222428;
myFormat.bold = 'true';
_buttonText.defaultTextFormat = myFormat;
_buttonText.text = text;
然后在我的进入帧我想调整文本的大小,我已经尝试了一些事情,但似乎没有工作,目前看起来是这样的。
myFormat.size = stage.stageWidth / 136.53;
感谢您的帮助
TextFormat对象除非应用于TextField,否则没有效果。此外,如果字体大小应该与舞台大小相关联,那么也应该应用某种因子大小。最后看起来像这样:
myFormat.size = 15 * fontSizeFactor;
//_buttonText.defaultTextFormat = myFormat;this is irrelevant if size should be dynamic.
//instead text should be set then TextFormat should be set again.
_buttonText.text = text;
_buttonText.setTextFormat(myFormat);//this is dynamic
现在进入帧:
myFormat.size = 15 * fontSizeFactor;
_buttonText.setTextFormat(myFormat);//apply the format again or else nothing will happen