10 Replies Latest reply on Aug 13, 2010 12:24 PM by kglad

    Make a URL click-able

    Ron Colmen Level 2

      How do I use getURL to make the pulled in data click-able or how do I make a URL which was pulled from a mysql to be click-able? (msgA[3])

       

       

       

      receiveLoad.onData = function(src) {

           var messageA:Array = src.split(",,,");

           var charCount = 0;

           var formatIndices = new Array();

           notice.text = "";

       

           for(var i:Number=0; i<messageA.length; i++){

                 var msgA:Array = messageA[i].split(",,");

                 notice.text += msgA[0]+"\n"+msgA[1]+"\n"+msgA[2]+"\n"+msgA[3]+"\n\n";

                 formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[0].length};

                 charCount = notice.text.length;

           }

       

           for(var j:Number=0; j<formatIndices.length; j++){

                 notice.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);

           }

      }

        • 1. Re: Make a URL click-able
          kglad Adobe Community Professional & MVP

          html enable your textfield:

           


           

           

          receiveLoad.onData = function(src) {

               var messageA:Array = src.split(",,,");

               var charCount = 0;

               var formatIndices = new Array();

          notice.html=true;

               notice.text = "";

           

               for(var i:Number=0; i<messageA.length; i++){

                     var msgA:Array = messageA[i].split(",,");

                     notice.htmlText += msgA[0]+"<br>"+msgA[1]+"<br>"+msgA[2]+"<br><a href=' "+msgA[3]+" '>"+msgA[3]+"<\a><br><br>";

                     formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[0].length};

                     charCount = notice.text.length;

               }

           

               for(var j:Number=0; j<formatIndices.length; j++){

                     notice.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);

               }

          }

          • 2. Re: Make a URL click-able
            Ron Colmen Level 2

            Thanks once again Kglad.

             

            (I wish I had more points to offer.)

            • 3. Re: Make a URL click-able
              Ron Colmen Level 2

              One more thing here How can I add a horizontal line in white at the end of each notice?

               

              notice.htmlText += msgA[0]+"<br>"+msgA[1]+"<br>"+msgA[2]+"<br><a href=' "+msgA[3]+" '>"+msgA[3]+"<\a><br><hr><br><br>";

              • 4. Re: Make a URL click-able
                kglad Adobe Community Professional & MVP

                there's no easy way to control the color of the underscore (unless that text has the same color) but you can use the <u> tag to create an underscore.

                 

                but unless you want visible text to be underscored that's not much easier than adding exactly one line of dashes to your textfield.  the line won't be solid but that's about the easiest way to add something that looks like an hr.

                • 5. Re: Make a URL click-able
                  Ron Colmen Level 2

                  Oops! Sorry for my bad explanation.... I wanted a horizonal line to separate each notice. See my example below (Shown in red is my requirement)

                   

                  E.g.

                   

                  HEADLINE 1

                  12.08.2010

                  dummy text here. dummy text here. dummy text here. dummy text here.

                  URL: www.myweb.com/newarrivals.html


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

                   

                  HEADLINE 2

                  10.08.2010

                  dummy text here. dummy text here. dummy text here. dummy text here.

                  URL: www.myweb.com/events.html


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

                   

                   

                  HEADLINE 3

                  10.08.2010

                  dummy text here. dummy text here. dummy text here. dummy text here.

                  URL: www.myweb.com/events.html

                   

                  • 6. Re: Make a URL click-able
                    kglad Adobe Community Professional & MVP

                    i understand.

                     

                    you can use the following function to return a sequence of characters that occupy one line of your textfied.  pass the textfield, the character and the color:


                    function hrF(tf:TextField,char:String,color:Number):String{
                        var htmlS:String = tf.htmlText;
                        var newlineS:String = "";
                        if(tf.maxscroll==1){
                            var initialBottomScroll:Number = tf.bottomScroll;
                            while(tf.bottomScroll==initialBottomScroll && tf.maxscroll==1){
                                newlineS += char;
                                tf.htmlText = htmlS+newlineS;
                            }
                            newlineS = newlineS.substring(0,newlineS.length-2);
                            tf.htmlText = htmlS;
                            return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";
                           
                        } else {
                            tf.htmlText = htmlS+char;
                            var initialMaxScroll:Number = tf.maxscroll;
                            while(tf.maxscroll==initialMaxScroll){
                                newlineS += char;
                                tf.htmlText = htmlS+newlineS;
                            }
                            newlineS = newlineS.substring(0,newlineS.length-2);
                            tf.htmlText = htmlS;
                            return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";
                        }
                    }

                    1 person found this helpful
                    • 7. Re: Make a URL click-able
                      Ron Colmen Level 2

                      Thanks!

                       

                      It's a bit complicated to me. Which fields do I have to alter to get this working?

                       

                      function hrF(tf:TextField,char:String,color:Number):String{
                          var htmlS:String = tf.htmlText;
                          var newlineS:String = "";
                          if(tf.maxscroll==1){
                              var initialBottomScroll:Number = tf.bottomScroll;
                              while(tf.bottomScroll==initialBottomScroll && tf.maxscroll==1){
                                  newlineS += char;
                                  tf.htmlText = htmlS+newlineS;
                              }
                              newlineS = newlineS.substring(0,newlineS.length-2);
                              tf.htmlText = htmlS;
                              return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";
                             
                          } else {
                              tf.htmlText = htmlS+char;
                              var initialMaxScroll:Number = tf.maxscroll;
                              while(tf.maxscroll==initialMaxScroll){
                                  newlineS += char;
                                  tf.htmlText = htmlS+newlineS;
                              }
                              newlineS = newlineS.substring(0,newlineS.length-2);
                              tf.htmlText = htmlS;
                              return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";
                          }
                      }

                      • 8. Re: Make a URL click-able
                        kglad Adobe Community Professional & MVP

                        change nothing in that function just copy and paste it into your current scope.

                         

                        to call the function, wherever you want a dashed red line in the textfield notice, use:

                         

                        hrF(notice,"-",0xff0000);

                         

                         

                        to call the function, wherever you want a solid green line in notice, use:

                         

                        hrF(notice,"_",0x00ff00);

                         

                         

                        if you want a line of purple asterisks, use:

                         

                        hrF(notice,"*",0xff00ff);

                         

                        for example,

                         

                        receiveLoad.onData = function(src) {

                             var messageA:Array = src.split(",,,");

                             var charCount = 0;

                             var formatIndices = new Array();

                        notice.html=true;

                             notice.text = "";

                         

                             for(var i:Number=0; i<messageA.length; i++){

                                   var msgA:Array = messageA[i].split(",,");

                                   notice.htmlText += msgA[0]+"<br>"+msgA[1]+"<br>"+msgA[2]+"<br><a href=' "+msgA[3]+" '>"+msgA[3]+"<\a><br>"+hrF(notice,"_",0xff0000)+"<br>";

                                   formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[0].length};

                                   charCount = notice.text.length;

                             }

                         

                             for(var j:Number=0; j<formatIndices.length; j++){

                                   notice.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);

                             }

                        }

                        1 person found this helpful
                        • 9. Re: Make a URL click-able
                          Ron Colmen Level 2

                          Wow!!! Awesome.

                           

                          THANK YOU KGLAD.

                          • 10. Re: Make a URL click-able
                            kglad Adobe Community Professional & MVP

                            you're welcome.