如何使用 FlashDevelop、Haxe 和 Swfmill 嵌入和显示 png
我在使用 Haxe 和 FlashDevelop 构建的简单 Flash 应用程序中显示 png 文件时遇到问题。
采取的步骤
- 将 png 文件添加到我的项目中。
- 将 png 添加到库中
- 设置嵌入为位图的选项
- 为对象“PlayerBitmap”设置 Id
- 验证生成的 xml 看起来正确
然后尝试显示嵌入的图像:
var bitmap:Bitmap;
bitmap = new PlayerBitmap();
bitmap.x = 200;
bitmap.y = 200;
addChild(bitmap);
代码编译并生成一个 swf 文件,但图像未显示。 有什么指点吗?
I am having trouble getting a png file to display in a simple Flash application I am building using Haxe and FlashDevelop.
Step taken
- Added the png file to my project.
- Added the png to the library
- Set the option to embed as a bitmap
- Set an Id for the object "PlayerBitmap"
- Verified that the xml generated looks correct
I then try to display the embedded image:
var bitmap:Bitmap;
bitmap = new PlayerBitmap();
bitmap.x = 200;
bitmap.y = 200;
addChild(bitmap);
The code compiles and generates a swf file but the image is not shown.
Any pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通过创建两个简单的测试项目来加载图像解决了这个问题。
第一个成功了,第二个失败了。
拥有一个包的项目之间有一个区别。
我的 Main 工作项目没有包,它是这样编译的
-main Main
失败的项目是相同的,除了 main 位于一个包中并且它像这样编译
-main org.alexjeffery.Main
为了在我的 main 位于 org.alexjeffery 包中时加载图像,我将图像名称设置为 org.alexjeffery.PlayerBitmap 而不是 PlayerBitmap。
我现在已经写了一篇关于如何 的教程使用 FlashDevelop 和 Haxe 嵌入图像。
I have solved the issue by creating two simple test projects to load an image.
The first worked and the second failed.
There was one difference between the projects one had a package.
The working project my Main does not have a package it is compiled like this
-main Main
The failing project is identical except the main is in a package and it compiles like this
-main org.alexjeffery.Main
To get the image to load when my main was in the org.alexjeffery package I set the image name to org.alexjeffery.PlayerBitmap instead of PlayerBitmap.
I have now written a tutorial on how to embed images using FlashDevelop and Haxe.
时,您会得到什么
bitmap.bitmapData.getPixel
跟踪bitmap
bitmap.bitmapData.rect
update 1:< /strong> 你的 PNG 可能是交错的,或者其他类似的东西? swfmill 有隔行扫描图像的问题,如果我没记错的话...
greetz
back2dos
what do you get when you trace
bitmap
bitmap.bitmapData.rect
bitmap.bitmapData.getPixel
update 1: is your PNG maybe interlaced, or anything else like that? swfmill has problems with interlaced images, if i remember well ...
greetz
back2dos
很简单,打开项目的目录,然后转到源文件夹,然后将 *.png 文件粘贴到那里。 FlashDevelop 将自动检测到它们。
Simple, open the directory of the project, then go to the source folder, and then paste the *.png files there. They will automatically be detected by FlashDevelop.
您可能想查看 Haxe 手册上的此页面:
http://haxe.org/manual/target-flash-resources.html
基本上你需要:
You might want to check out this page on the Haxe manual:
http://haxe.org/manual/target-flash-resources.html
Basically you need: