繁体   English   中英

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

[英]as3 change font size as stage size changes

正如我所读,我想随着舞台大小的变化来更改字体大小。

我有私有的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对象无效。 此外,如果应将字体大小链接到舞台大小,则还应使用某种因子大小。 最后看起来像这样:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM