Flex 4使用“click”事件添加TextFlow锚点

时间:2011-07-11 19:22:42

标签: flex hyperlink tlf

鉴于以下内容:

private var errorHtml:String = "<TextFlow xmlns=\"http://ns.adobe.com/textLayout/2008\"><p>Existing account, please <a click=\"clickHandler(event);\">click here</a>.</p></TextFlow>";

然后在creationComplete上导入它:

errorMessageText.textFlow = TextConverter.importToFlow(errorHtml, TextConverter.TEXT_LAYOUT_FORMAT);

点击处理程序功能永远不会触发。但是,如果我将它直接添加到标记:

<s:textFlow>
  <s:TextFlow>
    <s:p>
        Existing account, please <a click=\"clickHandler(event);\">click here</a>.
    </s:p>
  </s:TextFlow>
</s:textFlow>

事件发生火灾。我看到如果您尝试导入为TEXT_FIELD_HTML_FORMAT:

,则会删除这些事件
  

注意:与TextField类不同,不支持ActionScript链接事件。它们都不是:link,a:hover和a:active styles。

是否也使用TEXT_LAYOUT_FORMAT删除了它们?

1 个答案:

答案 0 :(得分:1)

是的,它摆脱了所有'FlowElementMouseEvent'事件,令人讨厌。基本上在导入后,您需要返回并查找所有链接,然后添加FlowElementMouseEventhandler s。这里有一篇博客文章:http://flexdevtips.blogspot.com/2010/10/displaying-html-text-in-labels.html讨论了如何做到这一点。