[英]how to resize font to match the width on flash textInput component
我使用ActionScript 2.0,并从组件向舞台添加输入文本
我将宽度设置为120像素,如果它超出了textinout的宽度,我想减小字体大小
我该怎么办呢?
自动调整剂量工作。 此方法也很有效,因为它的inputtext组件不是text字段
txtCurrency.text = currency;
txtPrice.autosize = "right";
//You set this according to your TextField's dimensions
var maxTextWidth:Number = 75;
var f:TextFormat = txtPrice.getTextFormat();
//decrease font size until the text fits
while (txtPrice.textWidth > maxTextWidth || txtPrice.textHeight > maxTextHeight)
{
f.size = int(f.size) - 1;
txtPrice.setTextFormat(f);
}
尝试添加txtCurrency.text = currency;
在txtPrice.setTextFormat(f);
之后的while循环内txtPrice.setTextFormat(f);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.