1 Reply Latest reply on Dec 21, 2006 6:14 AM by peterent

    using the Textfield class

    xyco45 Level 1
      Is it possible to use the Textfield class to chang the value of a variable with the data type String to a different color? Like for example creating creating a sample variable

      public var testVar:String = "hello World" and then setting up a button so when you click it it triggers
      mx.Alert.show("did it work? " + testVar"); and it shows the "hello World" in a different color.. is that possible? and if its not possible with a Alert box, can Textfield class be used in anyway to make it so that when you use the string type variable in a data grid, or text area that it will display a different color? Any help on this at all would be a HUGE help, thanx in advanced.
        • 1. Re: using the Textfield class
          peterent Level 2
          You cannot change the color of a variable or of a String. You can change the color of text as it is displayed on the screen because it is being displayed through a TextField that has some formatting applied.

          The component the Alert uses to display text can have ALL of the text be one color, but you cannot mix colors. To do that you need a component that can display HTML text or use a TextField with custom TextFormats.

          The easiest way would be: <mx:Text text="Hello Wold" color='red" />

          If you need to use an Alert, check its documentation and look under the Style section. You can use a style sheet to change its text color:

          <mx:Style>
          Alert { color:red; }
          </mx:Style>