使用 Haxe 复制图像
我的目标是仅使用一张方形图像制作一张宽地图。 使用actionscript 3,解决方案是简单地从加载器创建新的位图:
var loader:Loader = new Loader();
loader.load(new URLRequest("xyz.png"));
this.addChild(loader);
var duplicationBitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData);
不幸的是,Haxe API 不允许这样做。我无法从加载器内容中获取位图数据...
有人有线索吗?谢谢。
My goal is to make a wide map using only one square image.
Using actionscript 3 the solution is to simply make new Bitmap from the Loader:
var loader:Loader = new Loader();
loader.load(new URLRequest("xyz.png"));
this.addChild(loader);
var duplicationBitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData);
Unluckily, Haxe API doesn't allow to do that. I can't get bitmapData from loader content…
Anyone has a clue? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
API 是一样的,所以我猜问题在于你如何尝试转换;尝试使用:
The API is the very same, so I guess the problem is how you are trying to cast; try using:
你的意思是 API 不允许?通过查看这些:
http://haxe.org/api/flash9/display/loader
http://haxe.org/api/flash9/display/bitmap
看来你应该能够移植该代码?
您收到任何编译器错误吗?
J
What you mean the API doesn't allow it? By looking at these:
http://haxe.org/api/flash9/display/loader
http://haxe.org/api/flash9/display/bitmap
It seems you should be able to port that code?
Are you getting any compiler error?
J
这真的很奇怪,位图来自playerglobal.swc,不应该相关任何 Haxe 特定的“API”。您不是只是在内容尚未加载时尝试访问 loader.content (即上面的示例)。
That's really weird, Bitmap is coming from the playerglobal.swc and shouldn't be related to any Haxe specific "API". Aren't you just attempting to access loader.content whilst the content is not yet loaded (i.e. the example above).