1 2 Previous Next 45 Replies Latest reply on Sep 18, 2010 3:22 AM by Gaciwz

    Load-in text to be click-able

    Ron Colmen Level 2

      This continues with one of my previous posts.

       

      My requirement:

      When I pull-in the 'Notice Headlines' from a mysql db, I need each 'Notice Headline' to be click-able. When each 'Notice Headline' is clicked the relevant data should load in "abc_txt". How to do this?

       

      Current code:

      senderLoad.sendAndLoad("www.abc.com/myphp.php",receiveLoad,"POST");

      receiveLoad.onData = function(src) {

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

           messageA.pop();

      var charCount = 0;

           var formatIndices = new Array();

      noticeheading.html=true;

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

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

                 noticeheading.htmlText +=+msgA[0]+hrF(noticeheading,"_",0xFFFFFF)+"<br><br>";

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

                 charCount = noticeheading.text.length;

           }

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

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

           }

      };

        • 1. Re: Load-in text to be click-able
          kglad Adobe Community Professional & MVP

          use the <a> tag to create your link and the asfunction to execute the actionscript to load your text file.

          1 person found this helpful
          • 2. Re: Load-in text to be click-able
            Ron Colmen Level 2

            But shouldn't it be done using senderLoad? (the msg[2] will be sent to a php and by matching its text it will bring back the relevant NOTICE). How can I do that?.

             

            senderLoad.sendAndLoad("http://www.myweb.com/xyz.php",receiveLoad,"POST");

            receiveLoad.onData = function(src) {

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

                 messageA.pop();

                 var charCount = 0;

                 var formatIndices = new Array();

                 mybtn.html=true;

                 mybtn2.html=true;

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

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

              senderLoad.disloc2 = msgA[2];

                       mybtn.htmlText +="<FONT FACE='Arial'>"+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br><br>";

              mybtn2.htmlText +="<FONT FACE='Arial'><a href='http://www.myweb.com/abc.php'>"+msgA[2]+"</a><br>";

               senderLoad.sendAndLoad("http://www.abcweb.php",receiveLoad,"POST");

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

                       charCount = mybtn.text.length;

                 }

            • 3. Re: Load-in text to be click-able
              kglad Adobe Community Professional & MVP

              your asfunction will apply a sendAndLoad() method to a loadvars instance.

              • 4. Re: Load-in text to be click-able
                Ron Colmen Level 2

                I'm not really reading you - how the button will execute and pull-in the relevant data. But I gave it a try (doesn't seems to work though)

                 

                //continuation of the above post

                var senderLoadz:LoadVars = new LoadVars();

                var receiveLoadz:LoadVars = new LoadVars();

                 

                msgA[0].onRelease = function() {

                the_text.text="";

                senderLoadz.noticetopic = msgA[0];

                senderLoadz.sendAndLoad("http://www.abc.com/tri.php",receiveLoadz,"POST");

                receiveLoadz.onData = function(src) {

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

                //........

                 

                 

                $SomeVar = $_POST['noticetopic'];

                $query = "SELECT * FROM  db1 WHERE notice = '".$SomeVar."'";

                $results = mysql_query($query);

                • 5. Re: Load-in text to be click-able
                  kglad Adobe Community Professional & MVP

                  you'll use something similar to:

                   

                   

                  var sendLV:LoadVars=new LoadVars();
                  var receiveLV:LoadVars=new LoadVars();
                  receiveLV.onData=function(src){
                      // do whatever with src
                  }

                   

                  function loadText(textfileS:String) {
                  sendLV.sendAndLoad(textfileS,receiveLV,"POST");
                  }

                   

                  // whatever.txt and "Notice Headline" you'll parse from the data returned by your php file
                  noticeheading.htmlText = "<a href='asfunction:loadText, whatever.txt'>Notice Headline</a>";

                  • 6. Re: Load-in text to be click-able
                    Ron Colmen Level 2

                    I'm still lost. Should there be a senderLoad.somethnig = "XXXX"; to pick the relevant data?

                     

                    What I would like to do is

                    NOTICE 1, 2 and 3 will be pulled in at the statup (that part is done). When any item on the left is been clicked this should bring the relevant data from the mysql database.

                     

                    Eg. When 'NOTICE 2' is been clicked;

                     

                    NOTICE 1               NOTICE 2

                    NOTICE 2               Sample text. sample text.

                    NOTICE 3               The URL and the other info...

                     

                    CODE:

                    this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

                    this.createTextField("my_txt", this.getNextHighestDepth(), 385, 173, 422, 258);

                    this.createTextField("my_txt2", this.getNextHighestDepth(), 124, 173, 193, 258);

                     

                    senderLoad.disloc = "MICRO";

                    senderLoad.sendAndLoad("http://www.web.com/the.php",receiveLoad,"POST");

                    receiveLoad.onData = function(src) {

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

                         messageA.pop();

                         var charCount = 0;

                         var formatIndices = new Array();

                    my_txt.html=true;

                    my_txt2.html=true;

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

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

                               my_txt.htmlText +="<FONT FACE='Arial'>"+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br>";

                               my_txt2.htmlText +="<FONT FACE='Arial'><a href='asfunction:loadText, "+msgA[0]+"'>"+msgA[0]+"</a><br>";

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

                               charCount = my_txt.text.length;

                         }

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

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

                         }

                    };

                    function loadText(textfileS:String) {

                    senderLoad.disloc = msgA[0];

                    senderLoad.sendAndLoad("http://www.web.com/the2.php",receiveLoad,"POST");

                    }

                    • 7. Re: Load-in text to be click-able
                      kglad Adobe Community Professional & MVP

                      i don't understand:

                       

                      What I would like to do is

                      NOTICE 1, 2 and 3 will be pulled in at the statup (that part is done). When any item on  the left is been clicked this should bring the relevant data from the  mysql database.

                       

                      Eg. When 'NOTICE 2' is been clicked;

                       

                      NOTICE 1               NOTICE 2

                      NOTICE 2               Sample text. sample text.

                      NOTICE 3               The URL and the other info...

                       

                       

                      i expected to see something like:

                       

                      NOTICE 1               textfiletoloadwhennotice1isclicked.txt

                      NOTICE 2               adifferenttextfiletoloadwhennotice2isclicked.txt

                      etc

                      • 8. Re: Load-in text to be click-able
                        Ron Colmen Level 2

                        Sorry for my bad explanation.

                         

                        I need to load msgA[0] to a textField A. When clicked, the relevant data (msgA[0], msgA[1], msgA[2], msgA[3]...)should load in textField B.

                         

                        Image:

                        sample.jpg

                        • 9. Re: Load-in text to be click-able
                          kglad Adobe Community Professional & MVP

                          what's that have to do with loading a text file?

                          • 10. Re: Load-in text to be click-able
                            Ron Colmen Level 2

                            There's no text files, the data should loaded from the mysql db.

                             

                            How add the following to the above code.

                            1. how to make the data clickable in my_text2

                            2. how to get the relevant data in to my_text, by clicking each record in my_text2

                             

                            Sorry for any inconvenience caused.

                             

                            • 11. Re: Load-in text to be click-able
                              kglad Adobe Community Professional & MVP

                              use:

                               

                              function loadText(s:String) {
                              my_text.text = s;
                              }


                              my_text2.htmlText = "<a href='asfunction:loadText, text associated with Notice Headline 1'>Notice Headline 1</a>";

                              • 12. Re: Load-in text to be click-able
                                Ron Colmen Level 2

                                Ok, my_text2 is now click-able but when it's clicked instead of displaying the data on my_txt, it opens a php file in the browser (marked in red).

                                 

                                senderLoad.disloc = "HEADLINE 1";

                                senderLoad.sendAndLoad("http://www.web.com/file.php",receiveLoad,"POST");

                                receiveLoad.onData = function(src) {

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

                                     messageA.pop();

                                var charCount = 0;

                                     var formatIndices = new Array();

                                my_txt.html=true;

                                my_txt2.html=true;

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

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

                                           my_txt.htmlText +="<FONT FACE='Arial'>"+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br>";

                                           my_txt2.htmlText = "<a href='asfunction:loadText, "+msgA[0]+"'>"+msgA[0]+"</a>";

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

                                           charCount = my_txt.text.length;

                                     }

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

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

                                     }

                                };

                                function loadText(s:String) {

                                my_txt.text = "";

                                my_txt.text = s;

                                }

                                • 13. Re: Load-in text to be click-able
                                  kglad Adobe Community Professional & MVP

                                  it will display msgA[0] if you've coded that correctly.

                                  • 14. Re: Load-in text to be click-able
                                    Ron Colmen Level 2

                                    When I add the following it doesn't show any text in my_txt2?


                                    "+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br>

                                     

                                     

                                    CODE:

                                    my_txt2.htmlText += "<a href='asfunction:loadText, "+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br>'>"+msgA[2]+"</a><br>";

                                    //continues...

                                     

                                    //is the problem here?

                                    function loadText(s:String) {

                                    my_txt.text = "";

                                    my_txt.text = s;

                                    }

                                    • 15. Re: Load-in text to be click-able
                                      Ron Colmen Level 2

                                      I used the +newline+. It worked! 

                                       

                                      THANK YOU KGLAD for guiding me!!

                                      • 16. Re: Load-in text to be click-able
                                        Ron Colmen Level 2

                                        One more question.

                                         

                                        With that code how do I make the final appearance similar to this (format1)?

                                         

                                         

                                        receiveLoad.onData = function(src) {

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

                                             messageA.pop();

                                        var charCount = 0;

                                             var formatIndices = new Array();

                                        my_txt.html=true;

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

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

                                                   my_txt.htmlText +="<FONT FACE='Arial'>"+msgA[0]+"<br>"+msgA[1]+" "+msgA[2]+"<br>"+msgA[3]+"  "+msgA[4]+"<br>"+msgA[5]+"<br>"+msgA[6]+"<br><a href='mailto:msgA[7]'>"+msgA[7]+"<\a><br><br><br>";

                                         

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

                                                   charCount = my_txt.text.length;

                                             }

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

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

                                             }

                                        };

                                        • 17. Re: Load-in text to be click-able
                                          kglad Adobe Community Professional & MVP

                                          are you trying to format my_text.text?


                                          • 18. Re: Load-in text to be click-able
                                            Ron Colmen Level 2

                                            yes. I want msgA[0] to be #C0C0C0 & font size 20


                                            CURRENT CODE:

                                            receiveLoad.onData = function(src) {

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

                                                 messageA.pop();

                                                 var charCount = 0;

                                                 var formatIndices = new Array();

                                                 my_text2.html=true;

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

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

                                                       my_text2.htmlText +="<FONT FACE='Arial' COLOR='#00FF00' SIZE='12'><b><a href='asfunction:loadText,"+msgA[0]+newline+msgA[1]+msgA[2]+newline+msgA[3]+msgA[4]+newli ne+msgA[5]+newline+'Venue: '+msgA[6]+newline+'Time: '+msgA[7]+"'>"+msgA[0]+"</a><br>";

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

                                                       charCount = my_text.text.length;

                                                 }

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

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

                                                 }

                                            };

                                            function loadText(s:String) {

                                                 my_text.text = "";

                                                 my_text.text = s;

                                            }

                                             

                                            Can the '+newline+ be replaced by <br> so the entire line could be written as a htmlText? (When I tried that there was no text shown at all).

                                            • 19. Re: Load-in text to be click-able
                                              kglad Adobe Community Professional & MVP

                                              you can use the following function to format any text:

                                               

                                              function formatF(tf:TextField,s:string,tfor:TextFormat):Void{

                                              tf.setTextFormat(tf.indexOf(s),tf.indexOf(s)+s.length,tfor);

                                              }

                                               

                                              for example:

                                               

                                              formatF(my_text,msgA[0],format1);

                                              • 20. Re: Load-in text to be click-able
                                                Ron Colmen Level 2

                                                I did this. but no luck.

                                                 

                                                var format1:TextFormat = new TextFormat();

                                                format1.bold = true;

                                                format1.color = 0xC0C0C0;

                                                format1.size = 20;

                                                 

                                                function formatF(tf:TextField,s:String,tfor:TextFormat):Void{

                                                tf.setTextFormat(tf.indexOf(s),tf.indexOf(s)+s.length,tfor);

                                                }

                                                 

                                                function loadText(s:String) {

                                                     my_text.text = "";

                                                     my_text.text = s;

                                                     formatF(my_text,msgA[0],format1);

                                                }

                                                • 21. Re: Load-in text to be click-able
                                                  kglad Adobe Community Professional & MVP

                                                  is msgA[0] a substring of s?

                                                  • 22. Re: Load-in text to be click-able
                                                    Ron Colmen Level 2

                                                    Yes. My final code is in the 18th post in this thread.

                                                     

                                                    <a href='asfunction:loadText,"+msgA[0]+newline+msgA[1]+msgA[2]+newline+m sgA[3]+msgA[4]+newline+msgA[5]+newline+'Venue: '+msgA[6]+newline+'Time: '+msgA[7]+"'>"+msgA[0]+"</a><br>";
                                                    • 23. Re: Load-in text to be click-able
                                                      kglad Adobe Community Professional & MVP

                                                      msgA is out of scope in loadText().  use the trace function to confirm and it will probably be undefined.

                                                      • 24. Re: Load-in text to be click-able
                                                        Ron Colmen Level 2

                                                        correct, it says undefined. How to correct this?

                                                        • 25. Re: Load-in text to be click-able
                                                          kglad Adobe Community Professional & MVP

                                                          pass it to loadText and then to formatF and fix both so they accept that 2nd parameter.


                                                          • 26. Re: Load-in text to be click-able
                                                            Ron Colmen Level 2

                                                            something is wrong. I'm still getting 'undefined'.

                                                             

                                                            could you show me how it should be done?

                                                            • 27. Re: Load-in text to be click-able
                                                              kglad Adobe Community Professional & MVP

                                                              :

                                                               

                                                              function loadText(s:String) {
                                                                  var a:Array = s.split(",,");
                                                                   my_text.text = a[1];
                                                                   formatF(my_text,a[0],format1);
                                                              }

                                                               

                                                              my_text2.htmlText="<a href='asfunction:loadText,"+msgA[0]+",,"+msgA[0]+newline+msgA[1]+msgA[2]+newline+m sgA[3]+msgA[4]+newline+msgA[5]+newline+'Venue: '+msgA[6]+newline+'Time: '+msgA[7]+"'>"+msgA[0]+"</a><br>";

                                                              1 person found this helpful
                                                              • 28. Re: Load-in text to be click-able
                                                                Ron Colmen Level 2

                                                                still the color doesn't apply (format1). Just to check I even tried changing a[0] to a[1], nothing happened. (the trace displays the results though)

                                                                 

                                                                formatF(my_text,a[0],format1);

                                                                 

                                                                //is something wrong here?

                                                                function formatF(tf:TextField,s:String,tfor:TextFormat):Void{

                                                                tf.setTextFormat(tf.indexOf(s),tf.indexOf(s)+s.length,tfor);

                                                                }

                                                                • 29. Re: Load-in text to be click-able
                                                                  kglad Adobe Community Professional & MVP

                                                                  use the trace() function to pinpoint the problem.

                                                                  • 30. Re: Load-in text to be click-able
                                                                    Ron Colmen Level 2

                                                                    I used the trace(), all the necessary data seems to be working but just format1 is not applying.

                                                                     

                                                                     

                                                                    receiveLoad.onData = function(src) {

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

                                                                         messageA.pop();

                                                                         var charCount = 0;

                                                                         var formatIndices = new Array();

                                                                         my_txt2.html=true;

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

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

                                                                               my_txt2.htmlText +="<b><a href='asfunction:loadText,"+msgA[0]+",,"+msgA[0]+newline+msgA[1]+' '+msgA[2]+newline+msgA[3]+' '+msgA[4]+newline+msgA[5]+newline+'Time: '+msgA[6]+newline+'Venue: '+msgA[7]+"'>"+msgA[0]+"</a><br>";

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

                                                                               charCount = my_txt.text.length;

                                                                         }

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

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

                                                                         }

                                                                    };

                                                                     

                                                                    function formatF(tf:TextField,s:String,tfor:TextFormat):Void{

                                                                    tf.setTextFormat(tf.indexOf(s),tf.indexOf(s)+s.length,tfor);

                                                                    }

                                                                     

                                                                    function loadText(s:String) {

                                                                        var a:Array = s.split(",,");

                                                                         my_txt.text = a[1];

                                                                    formatF(my_txt,a[0],format1);

                                                                    //trace(a[0]);

                                                                    }

                                                                    • 31. Re: Load-in text to be click-able
                                                                      kglad Adobe Community Professional & MVP

                                                                      oops.  that should be:

                                                                       


                                                                       

                                                                      function formatF(tf:TextField,s:String,tfor:TextFormat):Void{

                                                                      tf.setTextFormat(tf.text.indexOf(s),tf.text.indexOf(s)+s.length,tfor);

                                                                      }

                                                                       


                                                                      • 32. Re: Load-in text to be click-able
                                                                        Ron Colmen Level 2

                                                                        Yes - that worked!

                                                                         

                                                                        Thank you Kglad. (I wish I had more points to offer)

                                                                        • 33. Re: Load-in text to be click-able
                                                                          kglad Adobe Community Professional & MVP

                                                                          you're welcome.

                                                                          • 34. Re: Load-in text to be click-able
                                                                            Ron Colmen Level 2

                                                                            How do I make the email in my_txt2 click-able? (msgA[7)]

                                                                            How do I add a subject line (email) to it?

                                                                             

                                                                            my_text2.htmlText +="<FONT FACE='Arial' COLOR='#00FF00' SIZE='12'><b><a href='asfunction:loadText,"+msgA[0]+newline+msgA[1]+msgA[2]+newline+m sgA[3]+msgA[4]+newline+msgA[5]+newline+'Venue: '+msgA[6]+newline+'Emal: '+msgA[7]+"'>"+msgA[0]+"</a><br>";

                                                                            • 35. Re: Load-in text to be click-able
                                                                              kglad Adobe Community Professional & MVP

                                                                              use an additional anchor link and asfunction.


                                                                              • 36. Re: Load-in text to be click-able
                                                                                Ron Colmen Level 2

                                                                                When I do so, no text appear.

                                                                                 

                                                                                my_txt2.htmlText +="<a href='asfunction:loadText,"+msgA[0]+",,"+msgA[0]+newline+msgA[1]+newline+msgA[2]+'  '+msgA[3]+'  '+msgA[4]+newline+msgA[5]+newline+'Telephone: '+msgA[6]+newline+"<a href='asfunction:fMailTo,"+msgA[7]+"'>"+msgA[7]+"'>"+msgA[0]+"</a></a><br>";

                                                                                • 37. Re: Load-in text to be click-able
                                                                                  kglad Adobe Community Professional & MVP

                                                                                  don't nest the anchor tags.  they should be in-line.

                                                                                  • 38. Re: Load-in text to be click-able
                                                                                    Ron Colmen Level 2

                                                                                    Is this the way to go about?

                                                                                    mailTo doesn't seem to be working. (trace doesn't work).

                                                                                     

                                                                                     

                                                                                    my_txt2.htmlText +="<a href='asfunction:loadText,"+msgA[0]+",,"+msgA[0]+newline+msgA[1]+newline+msgA[2]+'  '+msgA[3]+'  '+msgA[4]+newline+msgA[5]+newline+'Telephone: '+msgA[6]+"'>"+msgA[0]+"</a><a href='asfunction:mailTo,"+msgA[7]+"'>"+msgA[7]+"</a><br>";

                                                                                     

                                                                                     

                                                                                    function loadText(s:String) {

                                                                                        var a:Array = s.split(",,");

                                                                                         my_txt.text = a[1];

                                                                                    formatF(my_txt,a[0],format1);

                                                                                     

                                                                                    function mailTo(email) {

                                                                                    getURL("mailto:" + email);

                                                                                    //trace(Now it shows!!);

                                                                                    }

                                                                                    }

                                                                                     

                                                                                     

                                                                                    In the example below, assume RDA is (msgA[7]) what I'm trying to create the mailto: link

                                                                                     

                                                                                    sample.PNG

                                                                                    • 39. Re: Load-in text to be click-able
                                                                                      kglad Adobe Community Professional & MVP

                                                                                      your syntax is screwed-up.  try:

                                                                                       

                                                                                      "<a href='asfunction:loadText,"+msgA[0]+",,"+msgA[0]+newline+msgA[1]+newline+msgA[2]+' '+msgA[3]+' '+msgA[4]+newline+msgA[5]+newline+"Telephone: "+msgA[6]+"'>"+msgA[0]+"</a>"+newline+"<a href='asfunction:mailTo,"+msgA[7]+"'>"+msgA[7]+"</a><br>";

                                                                                      1 2 Previous Next