Flex:如何从htmlText锚点调用actionscript函数

时间:2009-05-16 00:15:07

标签: flex actionscript-3 textarea htmltext

有没有办法从TextArea组件的htmlText属性中定义的锚调用动作脚本函数。

谢谢

3 个答案:

答案 0 :(得分:5)

如果此锚是标记的href,您可以调度事件并按照以下方式处理它们:

<mx:Script>
    <![CDATA[
        private function linkHandler(e:TextEvent):void
        {
            if (e.text == "test")
                trace("test called")
        }
    ]]>
</mx:Script>
<mx:creationComplete>
    <![CDATA[
        textArea.htmlText="<a href='event:test'>Link!</a>";
    ]]>
</mx:creationComplete>

<mx:TextArea id="textArea" link="linkHandler(event)" />  

答案 1 :(得分:1)

我得到了答案here ..

答案 2 :(得分:0)

ExternalInterface类将为您提供Javascript和Actionscript之间的通信通道。使用此类,您可以从页面的Javascript中侦听调用,以及调度消息和数据。

以下链接引用AS 3.0。希望有所帮助!

ExternalInterface Docmentation

Usage Description

Sample Code