如何使用 FlashDevelop、Haxe 和 Swfmill 嵌入和显示 png

发布于 2024-07-27 14:23:47 字数 426 浏览 2 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谁与争疯 2024-08-03 14:23:48

我通过创建两个简单的测试项目来加载图像解决了这个问题。
第一个成功了,第二个失败了。
拥有一个包的项目之间有一个区别。

我的 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.

黎歌 2024-08-03 14:23:48

时,您会得到什么

  • 当您使用 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
  • some random pixels with 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

烈酒灼喉 2024-08-03 14:23:48

很简单,打开项目的目录,然后转到源文件夹,然后将 *.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.

落日海湾 2024-08-03 14:23:48

您可能想查看 Haxe 手册上的此页面:
http://haxe.org/manual/target-flash-resources.html

基本上你需要:

@:bitmap("relative/path/to/myfile.png") 
class MyBitmapData extends BitmapData { }

You might want to check out this page on the Haxe manual:
http://haxe.org/manual/target-flash-resources.html

Basically you need:

@:bitmap("relative/path/to/myfile.png") 
class MyBitmapData extends BitmapData { }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文