views:

2988

answers:

2

I'm trying to get StyleManager to have some effect, 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) seems to have any effect on the outcome.

What am I missing?

+4  A: 

Sorry, but StyleManager only affects components (I.E. classes in the fl.controls package), and can't be used to change styles or settings for instances of the TextField class.

There are other ways (kind of) to do what you're trying to do. For example, if you would like to use text fields but don't want to change a bunch of settings for each instance, you could subclass the TextField class and change a bunch of settings in the constructor, then just use your TextField subclass everywhere instead of TextField.

Hope this helps, and good luck.

BernzSed
A: 

If you wanted to affect the text colour of a textField. You can do it like so

myTextfield.textColor = "0xFF0000";

I hope that helps.

meridimus