Flex 中 JSON 作为 HTML 数据 - 超链接翻转
我正在使用 JSON 来解析带有 Flex 中自定义 html 标签的 HTML 数据。 Flex 对 HTML 的支持非常少,所以我想知道是否可以对这些链接执行简单的字体颜色更改翻转效果。目前我发现Flex只支持少数HTML标签,但通过Flex的whack CSS方法也支持CSS。
我可以通过外部 CSS 文件操作 JSON 文件中写入的 HTML 吗?或者更好地仍然使用带有 JSON 文件的简单标签?
I am using JSON to parse HTML data with customized html tags in Flex. Flex's support for HTML is pretty minimal, so I am wondering if it's possible to do a simple font color change rollover effect on these links. Currently I have found that Flex only supports a few HTML tags, but also supports CSS through Flex's whack CSS methods.
Can I manipulate HTML that is written in my JSON files through an external CSS file? Or better still using a simple tag with the JSON file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答:我认为没有灵丹妙药。这会很痛苦。
您可以首先以添加静态 StyleSheet 属性(例如 styleSheet:StyleSheet = null)的方式扩展 Text 类。然后创建一个包含以下样式的数组,这是 Flex 唯一支持的样式:
然后您必须初始化 StyleManager.selectors,创建要使用的选择器数组。基本上,您要找到“A”标签并向其添加上面的 listOfStyles,然后为每个样式创建一个新的 CSSStyleDeclaration。
这将允许您将上述命名的样式应用于扩展类的 htmlText 属性。到目前为止,一切都很好。这使您能够在加载时使用外部样式表为锚标记设置不同的样式。然而,要应用翻转效果(其中每个链接在 HTML 内翻转时更改颜色)会出现问题,因为 MouseEvent.MOUSE_OVER 将应用于整个类,而不是其中的各个 HTML 元素。您必须弄清楚鼠标是否位于该 HTML 文本中的锚点上(并非不可能,但我现在没有时间解决这个问题)并在其中更改您的选择器。这将涉及获取文本范围,这总是意味着大量的工作。当客户希望表情符号出现在文本流中时(Flex 的 HTML 实现无法支持其他功能),我不得不搞乱这一点,而且它非常粗糙。
我相信 Flex 4 将会为本机添加更多对此类事物的支持,但我还没有具体研究过。
抱歉,我没有灵丹妙药给你,但我希望这能让你对这个话题有所了解。
Short answer: I don't think there's a magic bullet for this. It's going to be a lot of pain.
You can start by extending the Text class in a way that adds a static StyleSheet property (e.g., styleSheet:StyleSheet = null). Then create an array which contains the following styles, the only ones supported by Flex:
Then you have to initialize the StyleManager.selectors, creating an array of selectors you are going to use. Basically, you are finding the "A" tag and adding the listOfStyles above to it, then creating a new CSSStyleDeclaration for each of those styles.
This will allow you to apply the above-named styles to the htmlText property of your extended class. So far so good. This enables you to set different styles to your anchor tags upon load, using an external stylesheet. To apply a rollover effect, however, where each link changes color on rollover within the HTML, would be problematic, since MouseEvent.MOUSE_OVER would apply to the class as a whole, not the individual HTML elements within it. You would have to figure out if the mouse was over an anchor within that HTML text (not impossible, but I don't have time to work that out right now) and change your selector within that. It would involve getting the text range, and that always means a lot of work. I had to mess with that when a client wanted emoticons to appear in the text flow (something else Flex's implementation of HTML fails to support) and it was extremely gnarly.
I believe Flex 4 is going to add more support natively for this kind of thing, but I haven't researched that specifically.
Sorry I don't have a magic bullet for you, but I hope this sheds a little light on the topic.
我不经常使用 Flex,所以没有太多深入的框架知识,但我想我
需要类似的东西:
这里是一个片段:
我只是使用内联字体标签,css可能会更好。这是我的原文问题。
哈特哈,
乔治
I don't use Flex often so not much in depth framework knowledge, but I think I
needed to something similar:
Here is a snippet:
I just used inline font tag, css might be better. Here is my original question.
HTH,
George