20 Replies Latest reply on Nov 27, 2006 2:56 PM by fanmap81

    html links: link from one text box to another

    fanmap81 Level 1
      Can anyone tell me how i can get a bunch of links from an external text file, rendered in a text box, link to another text file, that renders in another text box? Im trying to make it that when you click on the link in the first textbox, it opens up the corresponding linked content in the other textbox, instead of opening up a browser window. If anyone knows how to do this, it would be most appreciated. Thanks
        • 2. Re: html links: link from one text box to another
          fungusbogus
          Hi fanmap81
          I am not sure exactly what you're trying to do and I dont what your text file looks like. If I remember correctly, Flash is rather "picky" about the structure of the text content.


          Personally, I would prefer to get the content from an XML file and assign the value of each node to a separate textbox.
          Anyhow, I will try to answer in a manner that matches what you have described. Perhaps this will set you off in the right direction - even if its not the exact answer that you're looking for.

          To load the variables use
          loadVariables("data.txt", "_root.MyTextField");

          You should see the variables displayed in the "MyTextField" text box.
          To read the text from the textbox There are a few things that I do.
          1. Ensure that the text is selectable in the text box.
          2. Create a button with a function that will
          a. Read the value of the selected text.
          b. Load this value into a new text box.

          Hope this helps?
          • 3. Re: html links: link from one text box to another
            fanmap81 Level 1
            mmmmm not sure if thats what i want. I know how to load my initial text in already. In my external text file, i have links set up using <a href>. I just want my links to open up another text file inside another text box instead of clicking the link, and going to a new page or a new browser popup window. if u check the url:

            covalier.com/CB

            and then go to the page that says retailers, you will see wat it is i am trying to do. the first text box is a list of retailers, and the 2nd textbox is the address and map when you click on that retailer. At least thats whats supposed to happen anyway;-). Hope we can work this out
            • 4. Re: html links: link from one text box to another
              fungusbogus Level 1
              Ahh - I see!.
              I am afraid that the solution I have to offer may not be what you want to hear.

              Currently, the links are not active.(but I presume that you know that).
              As far as I am aware, marking them with <a href> tags will only cause them to respond as hyperlinks. Which essentially opens in a new page or reloads the existing one. I think you may be able to achive your goal with <a href> tags if you are using frames within a HTML based webpage. But I dont think that Flash likes frames? (Check on this.)

              What I would do, is dynamically load the text (Retailer Name) of each option into a button. (drop the <a href> tags)
              Then put code on the button so that it updates the right hand side box accordingly.

              something like this (WARNING - I have not tested this code)
              RName = the retailersname; //I presume that they have unique names.
              for each RName, make a call to the MakeButton function.

              MakeButton = function(){
              var rBtn = _root.createEmptyMovieClip(RName,getNextHighestDepth);
              RName.onPress = function(){
              //Insert code here to update the right hand side of the screen
              }
              var rTxt = Retailer.createTextField(RName,1,1,1,110,12);
              rTxt = RName;
              var TxtFmt = new TextFormat();
              TxtFmt.size = 12;
              TxtFmt.color = 0x0000EE;
              TxtFmt.autoSize = "left";

              rTxt.setTextFormat(TxtFmt);
              }

              • 5. Re: html links: link from one text box to another
                arunbe Level 1
                hi fanmap.

                Just read about asfunction , it may help you i think...
                • 6. Re: html links: link from one text box to another
                  fanmap81 Level 1
                  hmm i see the asfunction and it seems like what would work for what it is im trying to do.....how exactly would i go about setting this up however? my textboxes right now are named RetailList and RetailAddress, with the variables RetailListVariable and RetailAddress Variable in my text files. This is the code that i have in my movie currently:

                  stop();

                  loadText = new LoadVars();
                  loadText.load("TextFiles/RetailList.txt");
                  loadText.onLoad = function(success) {
                  if (success) {
                  // trace(success);
                  RetailList_txt.html = true;
                  RetailList_txt.htmlText = this.RetailListVariable;
                  }
                  };


                  loadText = new LoadVars();
                  loadText.load("TextFiles/RetailAddress.txt");
                  loadText.onLoad = function(success) {
                  if (success) {
                  // trace(success);
                  RetailAddress_txt.html = true;
                  RetailAddress_txt.htmlText = this.RetailAddressVariable;
                  }
                  };

                  how would i progress from this point to use asfunction to load my other text in when the hyperlink is clicked in the first text box?
                  • 7. Re: html links: link from one text box to another
                    arunbe Level 1
                    hi try this code.

                    and the text files should be like this...

                    //RetailAddress.txt
                    &RetailAddressVariable=<b><u><a href="asfunction:anymoreFunction">No 17 , Peter Church Road, <br>New Churchil, <br>New York</a></u></b>

                    //RetailList.txt
                    &RetailListVariable=<b><u><a href="asfunction:testCall, one">Click here to show list</a></u></b>
                    • 8. html links: link from one text box to another
                      fanmap81 Level 1
                      Im not too sure i understand whats going on here. I can get the text to show up in the retail list, but only some of the text are turning into clickable links, i dont know why this is happening. I have the links like this:

                      &RetailListVariable=<a href="asfunction:testCall, one">Click here to show list</a>
                      <a href="asfunction:testCall, GetSet">Get Set</a>
                      <a href="asfunction:testCall, FootLocker">FootLocker</a>
                      <a href="asfunction:testCall, DrJays">Dr. Jays</a>
                      <a href="asfunction:testCall, Friedmans Sport">Friedmans Sport</a>

                      and then, when i do click the ones that do become clickable, the retail address shows up in the other textbox, but its all the text that shows up, which i notice also becomes a clickable link, which im not looking for the address to become clickable. just the retail list links. How do i make it so that every link becomes clickable, and......when you click the link, it brings up a different address in the address text file? which currently looks like this:

                      &RetailAddressVariable=<a href="asfunction:anymoreFunction">No 17 , Peter Church Road, <br>New Churchil, <br>New York</a>
                      <a href="asfunction:anymoreFunction">Brickhouse World , Billy bart Road, <br>New Amsterdam, <br>New York</a>


                      all of that text shows up when the list button is clicked when i only want one address per link. Any idea?
                      • 9. Re: html links: link from one text box to another
                        arunbe Level 1
                        hi,
                        Actualy, i sent a sample source to find how to use the asfunction..
                        I cant get your problem by the previous thread..
                        if possible, send the code to us...
                        • 11. Re: html links: link from one text box to another
                          arunbe Level 1
                          hi,
                          the link is not working......... :(
                          • 14. Re: html links: link from one text box to another
                            fanmap81 Level 1
                            im trying to use that revised code, but its not working. It works in your file, but not in mine. Is it because my textboxes are inside of two movieclips and not the root? If this is the case, how do i alter the code for it to work, because i tried _root. in a few places, with no success.
                            • 15. Re: html links: link from one text box to another
                              arunbe Level 1
                              Instead of accessing directly,
                              You just give the instance name of the movieclip in which you are having the text feilds.
                              Suppose, you are having a text Feild inside a movieclip with the name "my_mc".
                              then ,
                              _root.my_mc.RetailList_txt = "text".
                              • 16. Re: html links: link from one text box to another
                                fanmap81 Level 1
                                alright i got it to work......it seems that if you embed the text in the textbox, it wont work. I have one last thing to ask. How do i write the code to make it increment by 1 for each new variable. The way it is now it seems i would have to write my actionscript like this:

                                function testCall() {
                                loadText = new LoadVars();
                                loadText.load("TextFiles/RetailAddress.txt");
                                loadText.onLoad = function(success) {
                                if (success) {
                                RetailAddress_txt.text = "";
                                RetailAddress_txt.html = true;
                                RetailAddress_txt.htmlText = this.RetailAddressVariable;
                                }
                                };
                                }
                                function testCall1() {
                                trace("Called !");
                                loadText = new LoadVars();
                                loadText.load("TextFiles/RetailAddress.txt");
                                loadText.onLoad = function(success) {
                                if (success) {
                                RetailAddress_txt.text = "";
                                RetailAddress_txt.html = true;
                                RetailAddress_txt.htmlText = this.RetailAddressVariable1;
                                }
                                };
                                }
                                function testCall2() {
                                loadText = new LoadVars();
                                loadText.load("TextFiles/RetailAddress.txt");
                                loadText.onLoad = function(success) {
                                if (success) {
                                RetailAddress_txt.text = "";
                                RetailAddress_txt.html = true;
                                RetailAddress_txt.htmlText = this.RetailAddressVariable;
                                }
                                };
                                }
                                function testCall3() {
                                trace("Called !");
                                loadText = new LoadVars();
                                loadText.load("TextFiles/RetailAddress.txt");
                                loadText.onLoad = function(success) {
                                if (success) {
                                RetailAddress_txt.text = "";
                                RetailAddress_txt.html = true;
                                RetailAddress_txt.htmlText = this.RetailAddressVariable1;
                                }
                                };
                                }


                                But wisdom is telling me that if i have 100 retailers, it dosent look to be the wisest of options too place testcall1-100 throughout my actionscript, and have an extremely long set of code. Im looking to increment the testcall by 1 in my text files, so that flash knows to go to the next retailer. I hope you understand what it is im saying. Thank you for your help thus far. Much appreciated.
                                • 17. Re: html links: link from one text box to another
                                  Tony Heagren
                                  I can tell you that "a bunch" is the collective noun for grapes.
                                  An nothing else.
                                  • 19. Re: html links: link from one text box to another
                                    arunbe Level 1
                                    Hi fanmap81,

                                    Wrinting so many functions is not fair.
                                    So, if you are adding more retailers means then again you have to write more functions and will continue the same till you get a set of fixed retailers.
                                    So , its better you can use some variable that will be passed from the asfunctions and can get it in the Flash. So that you can identify that variable and can proceed according to that....
                                    • 20. Re: html links: link from one text box to another
                                      fanmap81 Level 1
                                      arunbe, im not quite sure i understand what it is your saying