1 Reply Latest reply on Apr 21, 2010 8:57 AM by Mainmanian

    Flex panel titleTextField.htmlText href link handler

    Mainmanian Level 1

      I am creating a custom panel in which, I want the titleTextField to have HTML text in which a word is clickable. I have below attached a mxml
      component code with the HTML text for the title. I don't know how  to provide for a link handler for the link event. I would have thought that the titleTextField or titleBar would have provided for a link handler, but it does not appear to be so. I appreciate any help. 
      Thanks, Ramesh

      ------------

      <?xml version="1.0" encoding="utf-8"?>
      <TextInputPanel xmlns="soapbox.util.*" xmlns:mx="http://www.adobe.com/
      2006/mxml"
               width="300" height="200"
               title="Registered classes"
               borderThicknessLeft="6" borderThicknessRight="6"
      borderColor="#395182" creationComplete="init()">
               <mx:Script>
                       <![CDATA[
                               private function init():void {
                                       this.titleTextField.htmlText = "I  want to <font color='#0000FF'><a
      href='event:learn'>learn</a></font> | <font  color='#0000FF'><a
      href='event:teach'>Teach</a></font>";
                               }
                       ]]>
               </mx:Script>

      </TextInputPanel>

        • 1. Re: Flex panel titleTextField.htmlText href link handler
          Mainmanian Level 1

          I found the answer in adding an EventListener listenign for the TextEvent.LINK event. The code is below.

           

          <?xml version="1.0" encoding="utf-8"?>
          <TextInputPanel xmlns="soapbox.util.*" xmlns:mx="http://www.adobe.com/2006/mxml"
              width="300" height="200"
              title="I want to learn"
              borderThicknessLeft="6" borderThicknessRight="6" borderColor="#395182" creationComplete="init()">
              <mx:Script>
                  <![CDATA[
                      private function init():void {
                          this.titleTextField.htmlText = "I want to <font color='#0000FF'><a href='event:learn'>learn</a></font> | <font color='#0000FF'><a href='event:teach'>Teach</a></font>";
                          this.titleTextField.addEventListener(TextEvent.LINK, learnHandler);
                      }
                      private function learnHandler(event:TextEvent):void {
                          trace("link clicked");
                      }
                  ]]>
              </mx:Script>
             
          </TextInputPanel>