2015-08-15 71 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

他們顯然不是一樣的,雖然他們應該是相同的。讓他們一樣,你不應該再犯這個錯誤。