Embed bitmap in ActionScript3

一个人想着一个人 提交于 2019-12-02 02:12:57

Looks like you are embedding correctly if you don't get an error transcoding. You should be able to get the bitmapData directly from the bitmap:

[Embed(source="picture.jpg")]
private var Picture:Class;

// create a bitmap of the embedded
var pic:Bitmap = new Picture();

// add to display list
addChild(pic);

// if you need to get the bitmapData for something else
var bitmapData:BitmapData = pic.bitmapData;

You don't need to instantiate as BitmapData and draw - you can simply:

[Embed(source="Assets/helicopter1.png")]
private var AssetClass:Class;

var bitmap:Bitmap = new AssetClass();

In some editors (at least my version of Intellij) the Embed tag is case sensitive. I got the exact same error you have when using [EMBED] but it worked great when I switched to [Embed]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!