[英]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.