4 Replies Latest reply on Nov 29, 2007 12:33 PM by NickTheNameless

    link to function in dynamic text field

    NickTheNameless Level 1
      so i have a dynamic text field that needs to display something like...

      You have been identified as Syd Barrett. If this is incorrect, click here

      the dynamic part is the name, Syd Barrett in this example, which is inserted via a variable. now how do i get the word "here" to become a link to an ActionScript function and be a different color?
        • 1. Re: link to function in dynamic text field
          Dewdan
          The only way I get the dinamic text to link is by actually hard coding the text in the actionScript here an example

          var myCSS = new TextField.StyleSheet();
          //Specify the location of the CSS file that you created earlier
          var cssURL = "../yourCSSFile.css";
          //Hard code some HTML text to display (for example purposes)
          yourText = function () {
          //Load CSS file
          myCSS.load(cssURL);
          //define onLoad handler
          myCSS.onLoad = function(success) {
          if (success) {
          /* If the style sheet loaded without error,
          assign it to the text object, and assign the HTML text to the
          text field*/
          myTextbioA.styleSheet = myCSS;
          myTextbioA.text = exampleTextA;
          //this should be ".htmlText",
          // but Flash seems to recognise that the textbox needs to display html anyway
          } else {
          myTextbioA.text = "Error loading CSS file!";
          }
          };

          //exampleTextA = "<P><span class='larger'><br>• some text</SPAN></P><P><span class='ayourCSSclass'>some text.</SPAN></P><P><span class='ayourCSSclass'>some text<br><b>some more text</b><br><A HREF=' http://www.yourSite.com' TARGET='blank'>HERE</A>.</SPAN></P>";
          };
          yourText ();
          • 2. Re: link to function in dynamic text field
            NickTheNameless Level 1
            i just want to clarify here.... your example will work for an actionscript function? i see it would well if i were linking to a url, but i need the word "here" to run a function. to use your example....

            <A HREF=' http://www.yourSite.com' TARGET='blank'>HERE</A> would be <A HREF='myFunction()' TARGET='blank'>HERE</A>

            in case i haven't explained myself well, here's a crude copy of what i'm currently using, which runs the function by clicking anywhere on the dynamic text field, not just the word "here"....
            • 3. Re: link to function in dynamic text field
              Bob Pierce
              I've been wondering how to do this too. There is a global function called asfunction, described in the AS language reference as: A special protocol for URLs in HTML text fields that allows an HREF link to call an ActionScript function.
              The code below does what you're after. Your useage doesn't need the parameter but I've included it for info. The parameter has to be a single string, so if you want to pass more than one value you'll need to parse them out in your function.
              • 4. Re: link to function in dynamic text field
                NickTheNameless Level 1
                wow, that's beautiful. thanks man, you rock!