Skip to main content
Inspiring
July 2, 2012
Answered

Embedded Bitmap Name Appends Class name

  • July 2, 2012
  • 1 reply
  • 802 views

Hi.

i have this class:

package {

        import flash.display.Sprite;

        [SWF(width = "1024", height = "768", backgroundColor = "#000000", frameRate = "30")]

        public class myclass extends Sprite {

                [Embed(source="myimage.png", mimeType="image/png")] public var myimage:Class;

        }

}

I compile the image directly into swf with mxmlc compiler. After i load the swf in a main application i can't retrieve it with the name "myimage" but have to use "myclass_myimage" instead....

var id:String = "myclass_myimage";

var ref:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(id) as Class;

var img:Bitmap = new ref() as Bitmap;

How can i specify that i want it to be compiled with "myimage" and not "myclass_myimage"? or is there another way to retrieve the image using "myimage"?

Cheers,

Harry

This topic has been closed for replies.
Correct answer Harry Kunz

I was able to find the solution. So i'm gonna share it to whoever runs into the same problem. I had to create a class for the image and embed the png there.

package {

        import flash.display.Sprite;

        [SWF(width = "1024", height = "768", backgroundColor = "#000000", frameRate = "30")]

        public class myclass extends Sprite {

                public var force_compile:myimage;

        }

}

package {

        import flash.display.Bitmap;

        import flash.display.BitmapData;

        [Embed(source="myimage.png", mimeType="image/png")]

        public class myimage extends BitmapData {

                public function myimage(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF) {

                       super(width, height, transparent, fillColor);

                }

        }

}

Good Luck

1 reply

Harry KunzAuthorCorrect answer
Inspiring
July 13, 2012

I was able to find the solution. So i'm gonna share it to whoever runs into the same problem. I had to create a class for the image and embed the png there.

package {

        import flash.display.Sprite;

        [SWF(width = "1024", height = "768", backgroundColor = "#000000", frameRate = "30")]

        public class myclass extends Sprite {

                public var force_compile:myimage;

        }

}

package {

        import flash.display.Bitmap;

        import flash.display.BitmapData;

        [Embed(source="myimage.png", mimeType="image/png")]

        public class myimage extends BitmapData {

                public function myimage(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF) {

                       super(width, height, transparent, fillColor);

                }

        }

}

Good Luck