0

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.

Chowzen
  • 321
  • 3
  • 12
  • Have you tried instantiating `pic` in your `JMouse` constructor instead of where you're currently doing it? – Marcela Jul 28 '15 at 15:15
  • I just did, now (probably again :) ), both declaring the var inside the constructor and declaring it up top and adding an instance in the constructor... no luck. – Chowzen Jul 28 '15 at 15:29

2 Answers2

1

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.

BotMaster
  • 2,233
  • 1
  • 13
  • 16
  • I've tried these in the constructor:: pic = new Picture() as Bitmap; and pic = new Picture(); ...which also fails... is that what you meant? – Chowzen Jul 28 '15 at 15:41
0

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.

Community
  • 1
  • 1
Chowzen
  • 321
  • 3
  • 12