【问题标题】:AS3: Setting default font, color, etc. of a TextField using the StyleManager classAS3:使用 StyleManager 类设置 TextField 的默认字体、颜色等
【发布时间】:2009-05-13 02:09:18
【问题描述】:

我正在尝试让 StyleManager 产生一些效果,但无济于事。

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);

    }

  }
}

没有值(例如selectablecolortextFormat 等,使用setStylesetComponentStyle 或其他)似乎对结果有任何影响。

我错过了什么?

【问题讨论】:

    标签: flash actionscript-3 styles textfield


    【解决方案1】:

    抱歉,StyleManager 只影响组件(即 fl.controls 包中的类),不能用于更改 TextField 类实例的样式或设置。

    还有其他方法(某种)来做你想做的事。例如,如果您想使用文本字段但不想为每个实例更改一堆设置,您可以子类化 TextField 类并在构造函数中更改一堆设置,然后在任何地方都使用您的 TextField 子类的文本字段。

    希望这会有所帮助,祝你好运。

    【讨论】:

      【解决方案2】:

      如果您想影响 textField 的文本颜色。你可以这样做

      myTextfield.textColor = "0xFF0000";
      

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-27
        • 2014-10-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-13
        相关资源
        最近更新 更多