多个文本实例的 Flex 自动换行问题
我有一个场景,我想动态地将文本单词添加到容器中,以便它形成一段文本,该文本段落根据父容器的大小整齐地包装。每个文本元素将具有不同的格式,并且将具有不同的用户交互选项。例如,想象一下文本“刚刚说出”。每个单词将在运行时一次一个地添加到容器中。在这种情况下,用户名将是粗体,如果单击将触发事件。与新闻文章相同。文本的其余部分只是纯文本,单击时不会执行任何操作。
现在,我使用的是 Flex 3,因此无法使用新奇的文本格式化工具。我已经实现了一个解决方案,其中单词被绘制到画布上,但这意味着单词被包裹在特定的 y 位置(我选择的任意值)。当调整容器大小时,单词仍然在该位置换行,从而留下大量空间。
我考虑过将每个文本元素添加到数组集合中,并将其用作平铺列表的数据源,但平铺列表不支持可变列宽(以我有限的知识),因此每个单词将使用相同的空间量,这是不太理想。
有谁知道如何将单词绘制到容器上,以便即使调整容器大小也可以在段落级别保留格式、事件和自动换行?
I have a scenario where I want to dynamically add words of text to a container so that it forms a paragraph of text which is wrapped neatly according to the size of the parent container. Each text element will have differing formatting, and will have differing user interaction options. For example, imagine the text " has just spoken out about ". Each word will be added to the container one at a time, at run time. The username in this case would be bold, and if clicked on will trigger an event. Same with the news article. The rest of the text is just plain text which, when clicked on, would do nothing.
Now, I'm using Flex 3 so I don't have access to the fancy new text formatting tools. I've implemented a solution where the words are plotted onto a canvas, but this means that the words are wrapped at a particular y position (an arbitrary value I've chosen). When the container is resized, the words still wrap at that position which leaves lots of space.
I thought about adding each text element to an Array Collection and using this as a datasource for a Tile List, but Tile Lists don't support variable column widths (in my limited knowledge) so each word would use the same amount of space which isn't ideal.
Does anyone know how I can plot words onto a container so that I can retain formatting, events and word wrapping at paragraph level, even if the container is resized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不只使用 mx:Text 组件和 html 文本(您可以从 htmlText 调用函数),并使用 html 标签应用不同的格式。
有关如何从 htmlText 字段触发函数的信息:
http://www.adobepress.com/articles/article.asp?p= 1019620
Why aren't you just using a mx:Text component and html text (you can call functions from htmlText), and apply different formatting using html tags.
For information on how to trigger a function from a htmlText field:
http://www.adobepress.com/articles/article.asp?p=1019620