嵌入 png 会引发错误 #1065:未定义变量 FlexVersion

Embedding png throws Error #1065: Variable FlexVersion is not defined

我找到了几篇有关变量 FlexVersion 和错误 1065 的文章,但似乎没有任何帮助。

编辑:我已经尝试实施几个关于将图像嵌入 flashDevelop 的指南,但结果相同。一切正常,直到我尝试添加嵌入图像,然后我收到上述错误。

这里没有人看到这个错误吗?

我的 Class(为了查明问题,我已将其精简为零):

package {
import flash.display.Sprite;
import flash.display.Bitmap;

public class JMouse extends Sprite {
    [Embed(source = "../lib/jacobsLadder.png")]
    private var Picture:Class;
    //private var pic:Bitmap = new Picture(); // THIS LINE

    public function JMouse() {
        init();
    }
    private function init():void {
    }
}

在行 "THIS LINE" 未被注释掉时抛出错误。我试过将 "as Bitmap" 添加到这一行的末尾,但没有成功。 我从我的文档 class:

中调用这个 class
jMouse = new JMouse();

文件 jacobsLadder.png 在我的 lib 文件夹中,我使用 FlashDevelop "Generate Embed Code." 我正在为 .NET 3.5 使用 FlashDevelop 5.0.1.3

有什么想法吗?

编辑:我也按照建议尝试了这个(和类似的变体): "The type of code you can run at variable declaration scope is limited. Creating an instance of Picture requires decoding and so will fail at that point. Instead create your instance of Picture within an instance methods or the constructor."

[Embed(source = "../lib/jacobsLadder.png")]
    public static var Picture:Class;

    public function JMouse() {
        var pic:Bitmap = new Picture();
        init();
    }

但是我得到了同样的错误。

您可以 运行 在变量声明范围内的代码类型是有限的。创建 Picture 的实例需要解码,因此此时会失败。而是在实例方法或构造函数中创建 Picture 实例。

答案:使用加载程序加载位图数据。

虽然OP(我)问的是如何嵌入文件,但是"Error #1065: Variable FlexVersion is not defined"issue这个神秘的问题显然是一个无法克服的问题,我希望遇到这个问题的任何人都能找到安慰以下内容(由 John Mark Isaac Madison 等人提供): How do you load a bitmap file into a BitmapData object?

虽然这本身不是答案,但它至少允许 OP 继续他的工作,而不是点燃他的房子。