1 Reply Latest reply on Jul 26, 2006 1:49 AM by codescodescodes

    Dynamic txtfields

      Hi all,

      I was wonder how i can change the color of the third charachter in a dynamic textfield, which gets its content from an external txt file. --> all text have this structure: "03: nameoftile". i want the : in a different colour!!

      Hope anyone can help me thx!!!!

        • 1. Dynamic txtfields
          First you will have to define a textFormat object. You can do this using the textFormat contructor and describing the properties you want to add. For example:

          var myTxtFormat = new TextFormat();
          myTxtFormat.color = #0xff0000;

          Then after you set up your textFormat object, you just apply that to your text field. Like this:

          TextField.setTextFormat(2, myTxtFormat);

          TextField will be the name of the dynamic text field you have set up and the number 2 is the index of the character that you want to apply the textFormat to. If you want to apply the txtFormat to a span of characters in your text field you can use this syntax:

          TextField.setTextFormat(2, 10, myTxtFormat);

          or you can apply it to the entire text field like this:


          There are a lot of other format options that you can add to the textFormat class. Consult your help files in Flash for a list of the possible properties. Here are just a few samples: