【发布时间】:2009-06-04 16:20:58
【问题描述】:
在 Flash 中,当用户单击 TextField 中的超链接时是否会发生任何事件?
【问题讨论】:
标签: flash actionscript textfield hyperlink
在 Flash 中,当用户单击 TextField 中的超链接时是否会发生任何事件?
【问题讨论】:
标签: flash actionscript textfield hyperlink
有:TextEvent.LINK,但它只适用于以“事件:”开头的链接。
tf.htmlText = "<a href=\"event:http://www.example.com\">Example</a><br>";
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
如果您不使用“事件:”语法来提取外部数据,您可能可以轻松编写一个快速的正则表达式来添加它。
【讨论】:
似乎可以,请查看reference。
【讨论】:
可以使用 TextField 事件“链接” - 当用户单击 TextField 中的超链接时调度它。
Adobe site 中提供了一个很好的示例。
【讨论】:
这是用“event:”前缀替换hrefs的代码(如上面的geraldalewis所建议的):
public static function hrefEvents(s:String):String {
var hrefRegex:RegExp = /href="/gm;
var output:String = s.replace(hrefRegex, "href=\"event:");
var dupe:RegExp = /event:event:/gm;
output = output.replace(dupe, "event:");
return output;
}
请注意,我确保撤消对已包含“事件:”的 href 的替换。 (我本可以在正则表达式中使用否定的前瞻断言,但我很懒惰。)
【讨论】: