Skip to main content
March 7, 2011
Question

TLF applying hyperlinks issue

  • March 7, 2011
  • 1 reply
  • 2398 views

Hi,

I have a textArea in which I have assigned a textflow. On the text if I want to apply a hyperlink then I give a URL and target. Now if I haven't applied any other formatting to the text it creates a hypelink and makes the text blue and underlined, which is the normal case.

Now suppose I change the fontSize of the text and then apply a hyperlink, then the link gets applied, but the text neither gets any color , nor does it become underlined.

But if I do a Ctrl + Click on the same text, my link gets opened. But the hyperlink styling doesn't get applied.

This is what I am doing for applying link to some text:

public function changeLink( urlLink : String, target : String,  extendToOverlappingLinks : Boolean):void
        {
            if ( myTextArea.textFlow && myTextArea.textFlow.interactionManager is IEditManager)
            {
                 IEditManager(myTextArea.textFlow.interactionManager).applyLink( url, _target, extendToOverlappingLinks);        

            }

     }

So why is this happening ?

Thanks

This topic has been closed for replies.

1 reply

Adobe Employee
March 9, 2011

I think the question might be what are you doing to apply the formatting? The blue underline comes from default values for the link properties linkNormalFormat, linkHoverFormat, and linkActiveFormat. These properties can be applied to any element, and will inherit down if not overridden. But if when you apply the format you are overriding the link properties as well, this could explain what you are seeing.

- robin

daslicht
Known Participant
May 6, 2011

Hello,

how can we set the default color for a link ? I have the same issue here.

I found this:

editor.textFlow.linkActiveFormat

and this:

http://blog.flexexamples.com/2009/06/28/styling-hyperlinks-in-a-textflow-object-in-flex-4/

but how to set editor.textFlow.linkActiveFormat

This is not working:

editor.textFlow.linkActiveFormat.color ="#0000ff";

editor.textFlow.linkActiveFormat.textDecoration="underline";

Where to read about the IEditManager and other interfaces, how/where to get started with such things  ?

I keep reading/learning

Marc

Adobe Employee
May 9, 2011

Example in http://blog.flexexamples.com/2009/06/28/styling-hyperlinks-in-a-textfl ow-object-in-flex-4/

You can copy the code below, which runs correctly.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/06/28/styling-hyperlinks-in-a-textflow-object-in-flex-4/ -->
<s:Application name="Spark_TextArea_textFlow_linkHoverFormat_test"
               xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/halo">
   
    <fx:Script>
        <![CDATA[
            import flashx.textLayout.conversion.TextConverter;
            import flashx.textLayout.elements.TextFlow;
            [Bindable]
            var markup:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
    "<TextFlow xmlns=\"http://ns.adobe.com/textLayout/2008\" whiteSpaceCollapse=\"preserve\" fontSize=\"16\" paragraphSpaceAfter=\"15\" paddingTop=\"4\" paddingLeft=\"4\">"+
        "<linkNormalFormat color=\"#00ff00\" textDecoration=\"underline\" />"+
        "<linkHoverFormat color=\"#ff0000\" textDecoration=\"underline\" />"+
        "<linkActiveFormat color=\"#ff00ff\" textDecoration=\"underline\" />"+
        "<format id=\"code\" backgroundColor=\"#000000\" backgroundAlpha=\"0.1\" fontFamily=\"_typewriter\" />"+
        "<p fontWeight=\"bold\">The following excerpt is from <a href=\"http://blog.flexexamples.com/\" target=\"_self\">Flex Examples</a>:</p>"+
        "<p>The following example shows how you can import a TextFlow object from an XML object in Flex 4 by using the static <span format=\"code\">TextFlowUtil.importFromXML()</span> method.</p>"+
        "<p>For more information, see <a href=\"http://blog.flexexamples.com/2009/06/25/importing-a-text-flow-from-an-xml-object-in-flex-4/\">\"Importing a text flow from an XML object in Flex 4\"</a>.</p>"+
    "</TextFlow>";
           
            [Bindable]
            var tf:TextFlow = TextConverter.importToFlow(markup,TextConverter.TEXT_LAYOUT_FORMAT);
        ]]>
    </fx:Script>
   
    <s:TextArea id="txtArea"
                textFlow="{tf}"
                editable="false"
                width="400"
                horizontalCenter="0"
                verticalCenter="0" />
   
</s:Application>

PS:

I used TextConverter.importToFlow instead of TextFlowUtil.importFromString, because the former one is a tlf function under our controls, while the latter one is a flex function. I'm accustomed to take advantage of our own functions.