2015-08-03 118 views
0

因爲它讀取我想在舞臺大小變化時更改字體大小。as3更改字體大小隨着舞臺大小的變化

我有私人變種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; 

感謝所有幫助

回答

1

的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 
+0

感謝那些真正幫助,現在,任何想法如何解決這個問題? 我試圖 sp.removechild sp.addchild 但它從來沒有幫助的問題 –

+0

TextField的增長或收縮取決於字體大小,它甚至可以根據TextFieldAutoSize財產移動。您必須根據其大小的變化,通過代碼重置其位置。 – BotMaster

+0

我寫過 _buttonText.autoSize = TextFieldAutoSize.CENTER; 但是,如果按鈕向左移動並變小,文本將在按鈕外面結束。 至少字體大小現在正在改變 –