9 Replies Latest reply on May 15, 2007 8:47 AM by Greg Dove

    Styling one element of a concatenation

    Bill Milhoan


      A user types input into 5 or so text fields. Following this a button is clicked which triggers a concatenation of all the fields. The result (with added spaces and punctuation) is then displayed in another field. The catch is that one of the input fields has to displayed as italicized. I have set a new format for the specific input field that causes the input text to be displayed as italicized. However, when all the fields are added together and displayed in the new text field, the formatting is either dropped or the text Field instance name is displayed.

      I can post specific code but basically it is this:

      //create format for input field
      var myformat_fmt:TextFormat = new TextFormat ();
      myFormat _fmt.italic = true;

      this.onEnterFrame = function () {
      myTextField_txt.setTextFormat(myFormat _fmt);
      }

      //a button to cause concatenation and display of results
      createTxt_btn.onRelease=function (){
      var myStringA_str:String = new String(textField1_txt + " (");
      var myStringB_str:String = new String(textField2+ "). ");

      //concat field called "complete_txt is displayed, html properties are set
      //this includes a botched attempt to add HTML formatting...crap ensues

      complete_txt.html = true;
      complete_txt.multiline = true;
      complete_txt.wordWrap = true;
      complete_txt.htmlText = myStringA_str + myStringB_str + "<i>myTextField_txt.</i>" +".";
      }

      The above code produces italic formating in the final string but I get the instance name (myTextField_txt) instead of the content of that field! Is there some operator that lets you use HTML tags with strings?

      There seems to be no documentation that talks about this specific case. Even if I don't use the strings and set the htmlText to be a mega-concatenation the required italic formating is shown with the name of the text field.

      (Meanwhile my cubicle neighbor keeps laughing and telling me to ditch Flash and use Java but that's another forum topic)

      Any thoughts would be very helpful.

      Bill