user45623
user45623

Reputation: 621

Embedded PNG: 1034 Type Coercion Failed

Every single tutorial says to do it like this, which used to work:

[Embed(source="/../images/MyImage.png",mimeType="image/png",smoothing="true")]
private static var ImageClass:Class;

//[...]

var bitmap:Bitmap = new ImageClass();

Again, this used to work, but now (when I use PNGs) it gives me Error #1034: Type Coercion failed: cannot convert MyImage_png$3e9131867d9df437bb131fa0f25e1d80-479819629@c756f89 to flash.display.Bitmap.

Note that this method also fails:

var bitmap:Bitmap = new Bitmap(new ImageClass());

Am I doing something wrong? How do you embed a PNG as a Bitmap? The PNG has transparency, if that matters.

Upvotes: 2

Views: 73

Answers (1)

user45623
user45623

Reputation: 621

Ah, finally figured it out. The image is no longer a Bitmap if you enable smoothing in the embed tag. This works:

[Embed(source="/../images/MyImage.png",mimeType="image/png")] //NO SMOOTHING
private static var ImageClass:Class;

//[...]
var bitmap:Bitmap = new ImageClass();

Upvotes: 1

Related Questions