AS3 中的自动缩放 TLF 文本
我需要一个动作脚本解决方案,它允许动态文本放入具有预定尺寸(x,y,宽度,高度)的文本框中,然后放大或缩小文本,使其与它一样大无需滚动即可在这些尺寸内。自动换行将是自动的,并且不会有任何段落中断。
我有一个使用 Flash 的经典文本的工作模型,但我希望能够利用 TLF 提供的内联样式。我只是还没有完全理解 TLF 的所有功能。
有谁知道这种情况是否已有解决方案 - 或者也许可以引导我走向正确的方向?
I'm needing an actionscript solution that will allow dynamic text to drop into a text box with pre-determined dimensions (x, y, width, height), and then will scale the text up or down so that it is as large as it can be within those dimensions without scrolling. Wordwrap would be automatic, and there would not be any paragraph breaks.
I have a working model using Flash's Classic text, but I would like to be able to utilize the in-line styling that TLF provides. I just don't quite have my mind wrapped around all the TLF features yet.
Does anyone know if there is an already existing solution to this situation - or could perhaps steer me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@phil:这应该有帮助: http://aaronhardy.com/flex/size- text-to-container/
在线演示,右键查看源代码。
@phil: This should help: http://aaronhardy.com/flex/size-text-to-container/
Online demo, right click for source code.
嗯 - 这应该可行,但我不确定 TLF 字体大小有多精确......无论如何:
现在 - 这基本上创建了一个 TextFormat 对象并将其字体大小设置为 myText< /em>(TextField)容器宽度(最大宽度)除以实际文本宽度。再次强调 - 如果 TLF 字体大小不是那么精确,则大小线必须是:
100 表示四舍五入到百分之一。
编辑:我真的相信这种方法不仅更简单,而且高效......我的意思是 - 这就是 TextField.textWidth 的要点......
Hm - this should work, but I am not sure over how precise the TLF font size is... Anyways:
Now - this basically creates a TextFormat object and sets it's font size to myText's (the TextField) container width (the maximal width) divided by the actual text width. Again - if the TLF font size is NOT so precise, the size line must be:
100 means it is rounded to hundredths.
edit: I really believe this method is not only much simpler, but also efficient... I mean - that is the point of TextField.textWidth...