2015-08-15 66 views
0

我试图嵌入我的自定义字体在Flash应用程序,但我得到的编译过程中出现以下错误:不能在AS3中嵌入字体时,Flash

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

C:\Users\trap\Downloads\flex_sdk_4.6\bin\test.as: Error: A file found in a source-path 'test' must have the same name as the class definition inside the file '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); 
     } 
    } 
} 

回答

0

我想你会需要你的文件重命名为“EmbeddedFonts.as”。编译器希望使用类名称将公共类名称存储在文件中。

0

那么,什么是错误消息说简单的英语?

A file found in a source-path 'test' must have the same name as the class definition inside the file 'EmbededFonts'.

让我们看看你的文件名:

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

又有什么文件中的类定义的名字吗?

public class EmbededFonts extends Sprite

他们显然不是一样的,虽然他们应该是相同的。让他们一样,你不应该再犯这个错误。