as3 随着舞台大小的变化而改变字体大小

as3 change font size as stage size changes

如上所示,我想随着舞台大小的变化而更改字体大小。

我有私有变量 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;

感谢您的帮助

除非应用于 TextField,否则 TextFormat 对象无效。此外,如果字体大小应该与舞台大小相关联,那么也应该应用某种因素大小。最后看起来像这样:

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