AS3: setting default font, color, etc. TextField using StyleManager class

I am trying to get the StyleManager to have some kind of effect but to no avail.

package {
  import flash.text.*;
  import flash.display.Sprite;
  import fl.managers.StyleManager;

  public class StyleManagerExample extends Sprite {

    public function StyleManagerExample():void {

      StyleManager.setComponentStyle(TextField, "selectable", false);

      var exampleTextField:TextField = new TextField();
      exampleTextField.text = "Something";

      addChild(exampleTextField);

    }

  }
}

      

No value (eg selectable

, color

, textFormat

etc., using setStyle

, setComponentStyle

or otherwise), it seems to affect the result.

What am I missing?

+1


a source to share


2 answers


Sorry, but StyleManager only affects components (IE classes in the fl.controls package) and cannot be used to change styles or settings for TextField instances.

There are other ways (kind of) to do what you are trying to do. For example, if you want to use text fields but don't want to change the set of parameters for each instance, you can subclass the TextField class and change the set of parameters in the constructor, and then just use your TextField subclass throughout the TextField.



Hope it helps and good luck.

+4


a source


If you want to influence the text color of the text box. You can do it like this

myTextfield.textColor = "0xFF0000";

      



I hope this helps.

+3


a source







All Articles