4 Replies Latest reply on Jul 1, 2010 10:09 PM by BhaskerChari

    How to put a Hyperlink in a FlexApplication.

    kiran7881 Level 1

      Hi ,


      Can anybody please tell me as how to put a Hyperlink in a FlexApplication.

      I have seen this LinkButton Option , but we dont want that .

      Any help from experts ..

      Thanks in advance .

        • 1. Re: How to put a Hyperlink in a FlexApplication.
          Ansury Level 3

          What is wrong with a LinkButton?

           

          In the LinkButton's click event handler do this:

           

          var request:URLRequest = new URLRequest("http://google.com");

          navigateToURL(request, "_self");//Or whatever target, see the livedocs

           

           

          It has the same effect.  Anyway, you can't put an anchor tag in a Flex app.

           

           

          If the above is too much work (lots of links), you could extend LinkButton and create a custom component that takes the url as an argument to eliminate the redundant code.

          • 2. Re: How to put a Hyperlink in a FlexApplication.
            =VA=FyreHeart

            You could also use a custom item renderer, depending on where you're trying to create the link. I created a simple MXML component like this:

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" height="100%" width="100%" horizontalScrollPolicy="off">
                <mx:Script>
                    <![CDATA[

                           [Bindable] private var myURL:String = '<a href="http://www.cnn.com">Click Here</a>';
                           //or generate your custom URL here
                    ]]>
                </mx:Script>
                <mx:Text id="URLdisplay" htmlText="{myURL}" height="100%" width="100%" />
            </mx:Canvas>

            • 3. Re: How to put a Hyperlink in a FlexApplication.
              Matt Le Fevre Level 4
              private function newBrowserWindow(url:String):void 
                      {
                          var urlRequest:URLRequest = new URLRequest(url);
                          navigateToURL(urlRequest, "_blank");
                      }

               

              http://mattlefevre.com/viewExample.php?tut=flex&proj=Image%20Hyperlink

               

               

              can be used on any component you hook it up to.

              • 4. Re: How to put a Hyperlink in a FlexApplication.
                BhaskerChari Level 4

                Hi Kiran,

                 

                I think you need a text being hyper linked as we do have in html we use anchor tag...If so then you can use the below:

                 

                <mx:Label id="hyperLinkText" color="blue" fontSize="15" text="Hyper Link Text" mouseOver="hyperLinkText.setStyle('textDecoration','underline')" mouseOut="hyperLinkText.setStyle('textDecoration','none')" useHandCursor="true" buttonMode="true" mouseChildren="false"/>

                 

                You can also use css styles and assign the styles dynamically in mouseOver and mouseOut events same as above...

                 

                <mx:Label id="hyperLinkText" color="blue" fontSize="15" text="Hyper Link Text" mouseOver="hyperLinkText.setStyle('styleName','hyperLinkText')" mouseOut="hyperLinkText.setStyle('styleName','normalText')" useHandCursor="true" buttonMode="true" mouseChildren="false"/>

                 

                .hyperLinkText
                  {
                   text-decoration:underline;
                   font-size:15;
                   color:blue;
                  }
                  .normalText
                  {
                   text-decoration:none;
                   font-size:15;
                   color:green;
                  }

                 

                 

                If this post answers your question or helps, please kindly mark it as such.


                Thanks,

                Bhasker Chari