Actionscript 3 根据标签宽度和字符串长度动态更新标签文本

Actionscript 3 根据标签宽度和字符串长度动态更新标签文本,actionscript-3,apache-flex,flex4,flex4.5,Actionscript 3,Apache Flex,Flex4,Flex4.5,我有一个标签,一个文本输入和一个按钮,如下所示 <s:TextInput id="inputTxt"/> <s:Label id="lbl" height="50" width="100" backgroundColor="blue"/> <s:Button id="btn" label="Marquee" height="40" width="80" click="btn_clickHandler(event)"/> 您能建议我如何计算displayF

我有一个标签,一个文本输入和一个按钮,如下所示

<s:TextInput id="inputTxt"/>
<s:Label id="lbl" height="50" width="100" backgroundColor="blue"/>
<s:Button id="btn" label="Marquee" height="40" width="80" click="btn_clickHandler(event)"/>  

您能建议我如何计算
displayFact
,以便根据
lbl.width
str.length
进行更改,并且
str
应该适合标签的宽度。

没有简单的方法,因为字符的宽度不是恒定的,字体也不相同

相反,如果您试图实现的只是隐藏可以使用

<s:Label id="lbl" height="50" width="100" maxDisplayedLines=1 backgroundColor="blue"/>

如果我使用maxDisplayLines=1,那么如果字符串很大,它会显示“早上好…”,因此我使用updateLabel()。无论如何,谢谢你的链接
<s:Label id="lbl" height="50" width="100" maxDisplayedLines=1 backgroundColor="blue"/>