3 Replies Latest reply on Jul 27, 2009 1:06 PM by Sam Elkholy

    How do I create dynamic text that contains links?

    maxrep2003

      Any help on htis is appreciated. I cannot find anything that has helped me on this;

       

      How do I make my email address and URL linkable

       

      This is the copy on my actions layer:

       

      loadText = new LoadVars();

      loadText.load("data.txt");

      loadText.onLoad = function() {

      name.text = this.name;

      email.text = this.email;

      location.text = this.location;

      };

      This is the copy in my data.txt file:
      name=John Doe&email=info@myemailaddress.com&location=thisismywebsite.com
        • 1. Re: How do I create dynamic text that contains links?
          maxrep2003 Level 1

          I should clarify that the link information needs to be in the .txt file so that I only have to change the .txt file and not the flash once live.

          • 2. Re: How do I create dynamic text that contains links?
            Sam Elkholy

            my solution for you is to use XML instead of plain text file. I've attached a working fla file with it's XML file. It is straight forward. make sure both files are in the same location or modify the load path in the fla to reflect the xml file location Good luck.

             

            P.S. you'll have to remove the "mailto" from the display text, I don't have the time to strip it out.

            • 3. Re: How do I create dynamic text that contains links?
              Sam Elkholy Level 1

              Here is the code, you'll have to setup 3 text fields with instance names myText, myTextEmail, myLocationText

               

              import flash.net.URLLoader;

              import flash.net.URLRequest;

              import flash.events.IOErrorEvent;

               

              var myLoader:URLLoader = new URLLoader();

              var myXML:XML;

               

              myLoader.load(new URLRequest("myinfo.xml"));

              myLoader.addEventListener(Event.COMPLETE, xmlLoaded);

              myLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

               

              function xmlLoaded(e:Event):void

              {

              myXML = new XML(myLoader.data);

              myText.text = myXML.myname;

              myTextEmail.text = myXML.myemail;

              myLocationText.text = myXML.mylocation;

              myTextEmail.addEventListener(MouseEvent.CLICK, sendMail);

              myLocationText.addEventListener(MouseEvent.CLICK, gotoURL);

               

              }

               

              function sendMail(e:MouseEvent):void

              {

              var urlRequest:URLRequest = new URLRequest(myTextEmail.text);

              navigateToURL(urlRequest);

              }

               

              function gotoURL(e:MouseEvent):void

              {

              var urlRequest:URLRequest = new URLRequest(myLocationText.text);

              navigateToURL(urlRequest);

              }

               

              function errorHandler(e:IOError):void

              {

              trace("text did not load");

              }