1 Reply Latest reply on Apr 23, 2009 10:17 AM by m_hartnett

    Underlining in htmlText if a TextArea

    josulliv101

      hello,

      I have had no success tracking down how to do this.

       

      I have <a> tags in the htmlText property of a TextArea. I want these links to be underlined only when the cursor hovers over them.

       

      I did not see a way to do this. I feel like I may be missing an easy way -- maybe doing it via css.

       

      Any help is appreciated.

      Joe

        • 1. Re: Underlining in htmlText if a TextArea
          m_hartnett Level 3

          This is a little tricky and I think misunderstood because the documentation is not very clear.

           

           

           

           

           

           

           

           

           

          If you read the documentation it states that the css can contain the states of the anchor tag but it actually means that the flash.text.stylesheet not your application style sheet needs to be modified.  If you need to control the action of the link then look at the link property of the TextArea.

          Here is a link on the way to do it and an example.

           

          http://bugs.adobe.com/jira/browse/FLEXDOCS-505

          <?xml version="1.0" encoding="utf-8"?>

           

          <mx:Application

           

           

          xmlns:mx="http://www.adobe.com/2006/mxml

          "

          layout="

           

          absolute" xmlns:local="*" creationComplete="ccHandler()"

          >

           

           

           

          <mx:Script>

          <![CDATA[

           

           

          private var hoverStyles:String = "a:hover { color: #ff00ff; text-decoration: underline; } "

          +

           

           

          "a:active { color: #00ffff; text-decoration: underline; }"

          +

           

           

          "a:link { color: #00cccc;}"

          ;

           

           

           

          private function setup():void

          {

           

           

          var ss:StyleSheet = new

          StyleSheet();

          ss.parseCSS(hoverStyles);

          ta.styleSheet = ss;

          }

           

           

           

          private function ccHandler():void

          {

          ta.htmlText =

           

          "Here is some text with a link to <a href='http://www.google.com' target='_blank'>Google</a>. Click it to go there"

          ;

          }

          ]]>

           

           

          </mx:Script>

           

           

           

          <mx:TextArea id="ta" x="56" y="10" width="266" height="127" initialize="setup()"

          />

          </mx:Application>