无法在AS3,Flash中嵌入字体

时间:2015-08-15 16:51:19

标签: actionscript-3 flash flex actionscript flex4.5

我正在尝试将自定义字体嵌入Flash应用程序中,但在编译期间出现以下错误:

  

C:\ Users \ trap \ Downloads \ flex_sdk_4.6 \ bin> mxmlc test.as

     

C:\ Users \ trap \ Downloads \ flex_sdk_4.6 \ bin \ test.as:错误:在源路径'test'中找到的文件必须与文件'EmbededFonts'中的类定义同名

这是我的代码:

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;

    public class EmbededFonts extends Sprite {

        [Embed(source = "dexter.ttf",
            fontName = "myFont",
            mimeType = "application/x-font",
            fontWeight = "normal",
            fontStyle = "normal",
            advancedAntiAliasing = "true",
            embedAsCFF = "false")]
        private var fontFontSample: Class;


        public function EmbededFonts() {
            super();

            var textFormat: TextFormat = new TextFormat();
            textFormat.font = "myFont";
            textFormat.bold = true;
            textFormat.letterSpacing = 10;

            var textField: TextField = new TextField();
            textField.width = 300;
            textField.embedFonts = true
            textField.text = "Use embeded font";
            textField.textColor = 0x0000ff;
            textField.setTextFormat(textFormat);

            this.addChild(textField);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我认为您需要将文件重命名为“EmbeddedFonts.as”。编译器希望使用类名本身将公共类名存储在文件中。

相关问题