1 Reply Latest reply on May 23, 2007 6:47 AM by absurd29

    Change color to a input textfield

    baggio2004
      hi all ,
      I have a input textfield, where user can write a word, i need pressing a button, that that word change color,
      for example,
      user write, "world" in a input texfield, and after he press on a button called red, and the word "world" become of color red

      Someone can hep me?
      Thank you very much.
        • 1. Re: Change color to a input textfield
          absurd29
          I put 2 buttons on stage, named: red_btn & blue_btn & an input text field named input_txt, then the following code on frame 1 of main timeline:

          //set red style:
          var redFormat:TextFormat = new TextFormat();
          redFormat.bold = true;
          redFormat.font = "Arial";
          redFormat.color = 0xFF0000;
          //set blue style:
          var blueFormat:TextFormat = new TextFormat();
          blueFormat.bold = true;
          blueFormat.font = "Arial";
          blueFormat.color = 0x0000FF;
          //
          var enteredText:String;
          //change the colour:
          red_btn.onRelease = function() {
          enteredText = input_txt.text;
          input_txt.setNewTextFormat(redFormat);
          input_txt.text = enteredText;
          };
          blue_btn.onRelease = function() {
          enteredText = input_txt.text;
          input_txt.setNewTextFormat(blueFormat);
          input_txt.text = enteredText;
          };