如何在 AS3 中加载图像的精灵序列时减少内存使用
我制作了一个包含 1000 张图像 (780 x 480) 大小的精灵序列的 *.swf 文件。之后,我将其嵌入到另一个类中进行显示,但每次它在运行时都会因为内存不足而崩溃(假设我有 2GB 内存空间)。在 AS3 中实现如此大的精灵序列并避免内存问题的最佳方法是什么?如果您有任何好的建议,请帮忙。非常感谢。
I've made a *.swf file of the sprite sequences of 1000 images with (780 x 480) size. After that I embed this with another one class to show but every time it crushes during run time because of insufficient memory (assume that I have 2GB memory space). Which is the best way to implement such big sprite sequences in AS3 by avoiding the memory problem? Please help if you have any good suggestions.. Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能正在尝试将它们一次全部加载到内存中。这是一个巨大的内存量。您确实不需要一次处理 1000 张图像。也许您可以一次加载 10 - 20 个,然后在运行序列时从内存中删除之前的一次。通过这种方式可以减少内存占用。
您是否在主 swf 中嵌入了 1000 张图像?在这种情况下,swf 的大小是多少?这将是巨大的,用户必须等待很长时间才能加载。动态加载图像可能是更好的方法,而不是嵌入主 swf。
You are probably trying to load them all at a time in memory. That is a huge amount of memory. You really don't need 1000 images at a time. May be you can load 10 - 20 at once and while running the sequence remove the previous onces from memory. In this way you can reduce the memory footprint.
And are you embedding 1000 images in the main swf? What is the size of the swf in that case? That will be huge and user have to wait too long to load. Instead of embedding in main swf, dynamically loading the images might be a better approach.
Embad,用户将如何下载那个巨大的 swf?如果您的目标是 Flash(而不是 AIR),我认为最好将图像存储在服务器上,并根据请求下载它们。如果您的目标是 AIR,请按照 Marty 的建议进行操作:将 swf 分成更小的 swf。
Embad, and how will user download that huge swf? If you're targeting flash (not AIR) I think it'll be better to store images on server, and download them by request. If you're targeting AIR, do as Marty propses: devide swf into smaller swfs.
你为什么不简单地将你的图像制作成视频呢?
Why don't you simply made a video of your images ?