views:

2057

answers:

3

Is there any way to call an action script function from an anchor which defined in TextArea component's htmlText property.

Thank you

A: 

The ExternalInterface class will provide you with a communication channel between Javascript and Actionscript. Using this class, you can listen for calls from the page's Javascript, as well as, dispatch messages and data back.

The links below are referencing AS 3.0. Hope that helps!

ExternalInterface Docmentation

Usage Description

Sample Code

turkeyburger
browser may not be support for external function, or javascript could be disabled..
Tolgahan Albayrak
A: 

i got the answer here..

Tolgahan Albayrak
+2  A: 

If this anchor is an href from an tag, you can dispatch events and handle them like that:

<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)" />
akurtser