如何频繁使用AS代码而不增加CPU使用率?

发布于 2024-10-23 16:16:46 字数 171 浏览 5 评论 0原文

我已经用AS在flash中创建了一个动画(补间动画),

我想在我的项目中多次使用它,但是CPU使用率增加了很多!

我想将我的动画保存为 swf 并将其加载到我的项目中。

是好主意吗?

怎么办呢?

你能建议我有效的方法吗?

谢谢...

i have created an animation (kind of tween) in flash by AS,

i want to use it more than once in my project, but CPU usage increase very much!

i think save my animate as swf and load it in my project.

is good idea?

how do it?

can you suggest me efficient way?

thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

浮华 2024-10-30 16:16:46

如果您的动画有 400 个块和多行,并且我假设在 Flash 中制作为矢量 MovieClip(即不是图像),那么您的 CPU 使用率来自 Flash,必须每帧绘制大量矢量。当您开始使用它的多个实例时,这一点尤其正确。

看一下 cacheAsBitmap (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#cacheAsBitmap)如果您只是移动图像(而不是缩放)或旋转它),或者按照 www0z0k 建议进行操作并将其绘制为 BitmapData 对象。

您还可以从 bit101 查看 SWFSheet - http://www.bit-101.com /blog/?s=swfsheet - 它基本上通过将动画绘制为一系列 PNG 图像来为您完成艰苦的工作,然后您可以将其加载到其中

If your animation is 400 bricks and multiple rows, and I assume made in Flash as a vector MovieClip (i.e. not an image), then your CPU usage is coming from Flash having to draw a ton of vectors every frame. This becomes especially true when you start using multiple instances of it.

Take a look at cacheAsBitmap (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#cacheAsBitmap) if you're only moving your image around (not scaling or rotating it), or do as www0z0k suggested and draw it out as BitmapData objects.

You can also check out SWFSheet from bit101 - http://www.bit-101.com/blog/?s=swfsheet - it basically does the hard work for you by drawing out your animation as a series of PNG images that you can then load in

子栖 2024-10-30 16:16:46

一些代码会有用。
但是如果您需要多次重复完全相同的动画(并且它是在运行时创建的),您可以在第一次播放动画时为每一帧调用 BitmapData.draw() 并存储该 BitmapDatas在 ArrayVector 中,以便下次显示它们,而不是原始动画

some code'd be useful.
but if you need to repeat exactly the same animation many times (and it's created at runtime) you can call BitmapData.draw() for each frame of animation when it's played for the first time and store that BitmapDatas in an Array or Vector to show them every next time instead of original animation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文