关于在 AS3 项目中嵌入资产(图像)
我正在使用flex sdk 4.5.1和flash开发来编译我的AS3项目。我有一些小图像,大约 12KB,使用 Loader 类加载它们是愚蠢的,所以嵌入是更好的解决方案。
但是,当我的主类顶部的这一行未注释时,我得到空白 swf
[Embed(source = "../assets/gui/play1.png", mimeType = "image/png")]
private var PlayUpImg:Class;
(当我注释掉它时,编译后的 swf 就可以了)
可能是什么错误。为什么我得到的是空白 swf?
我正在 FlashDevelop 中从事纯 AS3 项目
I am using flex sdk 4.5.1 and flash develop to compile my AS3 project. I have small images, about 12KB which is silly to load them using Loader class, so embeding is better solution.
However when this line at the top of my Main class is uncomented i get blank swf
[Embed(source = "../assets/gui/play1.png", mimeType = "image/png")]
private var PlayUpImg:Class;
(when i comment it out, the compilated swf is ok)
What could be the error. Why do I get the blank swf?
I am working on pure AS3 project in FlashDevelop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用“application/octet-stream”mimetype 将 png 图像嵌入为任意二进制数据。然后,您将使用
Loader
对象的loadBytes()
方法来加载 png 图像的二进制数据。以下是一个示例:[更新]
我知道这个答案已被接受,但这里有一个额外的好处。
You could try embing the png image as arbitrary binary data by using the "application/octet-stream" mimetype. Then you would use a
Loader
object'sloadBytes()
method to load the png image's binary data. The following is an example of this:[UPDATE]
I know this answer has already been accepted but here's an extra added bonus.
您需要将图像添加到显示列表中:
You need to add the image to the Displaylist: