【问题标题】:Flex: How to call an actionscript function from htmlText anchorFlex:如何从 htmlText 锚点调用动作脚本函数
【发布时间】:2009-05-16 00:15:07
【问题描述】:

有什么方法可以从 TextArea 组件的 htmlText 属性中定义的锚点调用动作脚本函数。

谢谢

【问题讨论】:

    标签: apache-flex actionscript-3 textarea htmltext


    【解决方案1】:

    如果此锚点是来自标签的 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)" />  
    

    【讨论】:

      【解决方案2】:

      我得到了答案here..

      【讨论】:

        【解决方案3】:

        ExternalInterface 类将为您提供 Javascript 和 Actionscript 之间的通信渠道。使用该类,您可以侦听来自页面 Javascript 的调用,以及发送消息和返回数据。

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

        ExternalInterface Docmentation

        Usage Description

        Sample Code

        【讨论】:

        • 浏览器可能不支持外部功能,或者javascript可能被禁用..
        猜你喜欢
        • 1970-01-01
        • 2012-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-15
        相关资源
        最近更新 更多