2 Replies Latest reply on Jul 25, 2007 7:31 AM by pandxsg

    dynamic text formatting

    pandxsg Level 1
      I'm new to dynamic formatting in text, and I found out from the tutorials that you can apply text formatting, but to a single dynamic textbox. But what if I've got a single dynamic textbox but wanted to apply different formatting for different text inside?

      For eg I've got a textbox with the instance name "myText".

      myText.text = "Hello World";

      I understand I can for eg, change the color of "Hello World" to yellow using:

      myformat = new TextFormat();
      myformat.color = 0xffff00; //yellow
      myText.setTextFormat(myformat);

      But how do I say, change "Hello" to yellow and "World" to red?

      Thanks!
        • 1. Re: dynamic text formatting
          Level 7
          pandx,

          > I understand I can for eg, change the color of "Hello World" to
          > yellow using:
          >
          > myformat = new TextFormat();
          > myformat.color = 0xffff00; //yellow
          > myText.setTextFormat(myformat);

          You got it.

          > But how do I say, change "Hello" to yellow and "World" to red?

          The answer to that is in the optional parameters available to the
          TextField.setTextFormat() method you're already using. :) Check out
          setTextFormat() in the ActionScript 2.0 Language Reference and you'll see
          that in addition to the TextFormat instance, you can also supply positions
          in the text field's string to start and stop your formatting.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: dynamic text formatting
            pandxsg Level 1
            I've got it working...Thanks for pointing me in the right direction!