Skip navigation
Mohammad Pourhossein
Currently Being Moderated

Click attribute in textFlow anchor tag in Flash Builder 4

Mar 25, 2010 3:37 AM

Hi folks,

At first congratulation to you, Adobe and Flex team for Adobe Flash Builder 4 & flex 4 SDK final release...

then, I have a click attribute in my textFlow anchor tag, just like this:


     import mx.controls.Alert;
     public function func():void{
<s:RichEditableText x="50" y="50" editable="false" id="RET" >
          <s:a href='' click='func()'>
               <s:img source='adobe.jpg' width='50' height='50' />


When I run the project, everything's allright; and after click on my image, I have adobe site in new window, and also have my popup alert window with "Hello!" text...

But the Problem is another thing. I want to give this textFlow content from one webservice and put it in a string var then bind it to my RichEditableText. I receive it from webservice, put it in the string, and then bind this string to textFlow attribute of my RichEditableText obj with simple function... after running my project, I can see the content, and when I click on my image, I have adobe site in new window, again. but my function does not call!

What is the problem?! the code is something like this (of course without webservice codes!):


     import flashx.textLayout.conversion.TextConverter;
     import mx.controls.Alert;
     public function func():void{
     internal var str:String;
     public function func2():void{
          str = "<TextFlow xmlns='' paddingRight='5'>"+
          "<a href='' click='func();'><img source='adobe.jpg' width='50' height='50' /></a>"+
          RET.textFlow= TextConverter.importToFlow(str, TextConverter.TEXT_LAYOUT_FORMAT);
<s:RichEditableText x="50" y="50" editable="false" id="RET" />

  • Currently Being Moderated
    Mar 25, 2010 6:44 AM   in reply to Mohammad Pourhossein

    Listening for a FlowElementMouseEvent.CLICK event will be beneficial.


    In your webservice feed (Textflow), have a tag such as:

    <a href="event:adobe.jpg">Click here to view Adobe's logo!</a>


    Then in your ActionScript code, listen for any FlowElementMouseEvent.CLICK events from your textFlow instance.



    Next, declare onLinkHandler:

               * In the XML there are href tag which has 'event:' prefix to the value.  This prefix
               * allows method calls.
              private function onLinkHandler(event:FlowElementMouseEvent):void
                   //extract the number value from the string.
                   var uri:String = LinkElement(event.flowElement).href.split(":")[1];
                   trace(uri);//outputs: adobe.jpg
    Mark as:
  • Currently Being Moderated
    Nov 26, 2012 12:46 AM   in reply to injpix

    Looks very well, but it works not well.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points