代码之家  ›  专栏  ›  技术社区  ›  Maksim Vi.

更改AS3组件字体

  •  0
  • Maksim Vi.  · 技术社区  · 15 年前

    我想通过flash-ide(不在操作脚本中)更改组件(在我的例子中是组合框)的字体名称、字体大小和字符嵌入属性。 有选择吗?

    谢谢。

    2 回复  |  直到 14 年前
        1
  •  4
  •   sberry    15 年前

    不,您需要使用actionscript来完成这项工作。我是这样做的:

    package com.twoa.ui.base.controls {
        import fl.controls.ComboBox;
        import fl.controls.List;
        import flash.text.Font;
        import flash.text.TextFormat;
    
        public class MyComboBox extends ComboBox {
    
            private var textFormat:TextFormat;
            private var textFormat2:TextFormat;
    
            public function MyComboBox() {
                super();
                forceStyle();
            }
    
            public function forceStyle() {
    
                var f:Font = new Interface();
    
                var textFormat:TextFormat = new TextFormat()
                textFormat.size = 8;
                textFormat.color = 0xffffff;
                textFormat.font = f.fontName
    
                var textFormat2:TextFormat = new TextFormat()
                textFormat2.size = 8;
                textFormat2.color = 0xffffff;
                textFormat2.font = f.fontName
    
                dropdown.setRendererStyle("embedFonts", true);
                dropdown.setRendererStyle("textFormat", textFormat);
    
                textField.setStyle("embedFonts", true);
                textField.setStyle("textFormat", textFormat2);
    
            }
    
        }
    }
    
        2
  •  -1
  •   Maksim Vi.    14 年前

    看起来没有办法设置默认flash组件的字体。最后我自己写了。

    推荐文章