Search code examples
actionscript-3embedded-resource

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


I've found several articles relating to variable FlexVersion and error 1065, but nothing seems to help.

EDIT:I've attempted to implement SEVERAL guides on embedding images into flashDevelop with the same result. Everything works correctly until I try to add the embedded image, then I get the above error.

Has no one here seen this error?

My Class (which I've stripped down to nothing in order to pinpoint the issue):

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 {
    }
}

throws the error when the line "THIS LINE" is not commented out. I've tried adding "as Bitmap" to the end of this line without luck. I am calling this class from my document class:

jMouse = new JMouse();

the file, jacobsLadder.png, is in my lib folder, and I used FlashDevelop to "Generate Embed Code." I am using FlashDevelop 5.0.1.3 for .NET 3.5

Any Ideas?

EDIT: I also tried this (and similar variations), as per the suggestion: "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();
    }

But I get the same error.


Solution

  • ANSWER: Load the bitmapdata with a loader.

    Although the OP (me) was asking how to embed the file, the mysterious problem of "Error #1065: Variable FlexVersion is not defined" issue is apparently an insurmountable one, and I hope that anyone else who may come across this problem may find solace in the following (courtesy of John Mark Isaac Madison et al): How do you load a bitmap file into a BitmapData object?

    While not the an answer, per se, it at least allows the OP to continue on in his work as an alternative to lighting his house on fire.