每个教程都说这样做,过去常常起作用:
[Embed(source="/../images/MyImage.png",mimeType="image/png",smoothing="true")]
private static var ImageClass:Class;
//[...]
var bitmap:Bitmap = new ImageClass();
同样,这曾经有用,但现在(当我使用PNG时)它给了我Error #1034: Type Coercion failed: cannot convert MyImage_png$3e9131867d9df437bb131fa0f25e1d80-479819629@c756f89 to flash.display.Bitmap.
请注意,此方法也会失败:
var bitmap:Bitmap = new Bitmap(new ImageClass());
我做错了吗?你如何嵌入PNG作为位图?如果重要的话,PNG具有透明度。
答案 0 :(得分:1)
[Embed(source="/../images/MyImage.png",mimeType="image/png")] //NO SMOOTHING
private static var ImageClass:Class;
//[...]
var bitmap:Bitmap = new ImageClass();