2011-01-20 24 views
0

我使用ActionScript 2.0工作,我的inputText從組件添加到階段如何調整字體以匹配閃光TextInput組件寬度

i中的寬度設定爲120像素 我想decrese的字體大小,如果它溢出textinout的寬度

我該如何實現它?

autosize dosent work。 這種方法也dosent工作,因爲它的inputText組件不是文本字段

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); 
} 
+1

在你的問題,你說你「用ActionScript 2.0的工作」,但標籤爲你提問是「actionscript-3」和「adobe-flash-cs5」。你使用AS2還是AS3? – Taurayi 2011-01-20 23:25:04

回答

0

嘗試添加 txtCurrency.text = currency; while循環中後 txtPrice.setTextFormat(f);

相關問題