是否可以使用 Flash CS4 [embed] 标签将资源导出到第 2 帧而不是第 1 帧?
我们正在开发一个 Flash CS4 项目,其中主 .fla 文件的大小已经膨胀,并且“发布”需要很长时间。我怀疑很大一部分大小(至少是一些编译时间)是由于库中音频符号的数量造成的。
我很想从 .fla 文件中删除这种不必要的膨胀。我尝试过从库中删除音频符号并使用 [embed]
元数据标记,如下所示:
[Embed(source="audio/music/EndOfLevelDitty.mp3")]
public var EndOfLevelDitty:Class
生成的已发布文件工作完美,但存在问题。我们的游戏在时间线的第一帧上使用预加载器,因此所有其他类都需要在第 2 帧中导出(如发布设置 > ActionScript 3.0 设置中的设置)。因此,大小报告通常是这样开始的:
Frame # Frame Bytes Total Bytes Scene ------- ----------- ----------- ---------------- 1 284515 284515 Scene 1 2 5485305 5769820 (AS 3.0 Classes Export Frame)
但是,如果我在小声音上使用 [embed]
标签,我的大小报告现在是:
Frame # Frame Bytes Total Bytes Scene ------- ----------- ----------- ---------------- 1 363320 363320 Scene 1 2 5407240 5770560 (AS 3.0 Classes Export Frame)
如您所见,嵌入的声音已导出到框架中1 而不是第 2 帧。如果我以这种方式嵌入所有声音,第 1 帧的大小将会变得巨大,并且在加载预加载器帧之前,用户将长时间看着白屏。
所以我的问题是:我可以使用 [embed]
标签,但将嵌入式资源导出到第 2 帧而不是第 1 帧中吗?
项目限制:
- 我们的团队构成意味着我们现阶段还不能转向纯Flex。
- 编译后的 .swf 需要“一体化”,因此我们无法将预加载器拆分为单独的文件,并且无法访问外部资源。
编辑:我也愿意将音频放在嵌入式库 SWC 中,但似乎也没有办法将其嵌入到第 2 帧中;它总是以第 1 帧结束。
We're working on a Flash CS4 project where the main .fla file has ballooned in size and 'Publish' is taking forever. I suspect a large amount of the size (and at least some of the compile time) is due to the quantity of audio symbols in the library.
I would love to remove this unnecessary bloat from the .fla file. I've experimented with removing an audio symbol from the library and using the [embed]
metadata tag instead, like so:
[Embed(source="audio/music/EndOfLevelDitty.mp3")]
public var EndOfLevelDitty:Class
The resulting published file works perfectly, but there is a problem. Our game uses a preloader on the first frame of the timeline, so all other classes need to be exported in frame 2 (as set in Publish Settings > ActionScript 3.0 Settings). So a size report normally begins like this:
Frame # Frame Bytes Total Bytes Scene ------- ----------- ----------- ---------------- 1 284515 284515 Scene 1 2 5485305 5769820 (AS 3.0 Classes Export Frame)
However, if I use an [embed]
tag on a small sound, my size report is now:
Frame # Frame Bytes Total Bytes Scene ------- ----------- ----------- ---------------- 1 363320 363320 Scene 1 2 5407240 5770560 (AS 3.0 Classes Export Frame)
As you can see, the embedded sound has been exported into frame 1 rather than frame 2. If I were to embed all sounds in this manner, the size of frame 1 would grow to be huge, and users would be looking at a white screen for ages before the preloader frame even loaded.
So my question is this: can I use an [embed]
tag but have the embedded asset export in frame 2 instead of frame 1?
Project constraints:
- Our team composition means we can't change to pure Flex at this stage.
- The compiled .swf needs to be 'all in one', so we can't split the preloader into a separate file, and we can't access external resources.
Edit: I'd also settle for having the audio in an embedded library SWC, but there seems to be no way to make that embed in frame 2 either; it always ends up in frame 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最后,我厌倦了 Flash 中的所有混乱,并决定(仅)在 Flex 中构建预加载器,将游戏 SWF 嵌入预加载器中并使用 SWFLoader 加载它。 (这是基于 Myk 的建议。)最后我仍然可以得到一个 SWF,由 Flex 更强大的预加载系统处理预加载器显示。
我最终没有使用完整的 Flex Builder;我刚刚使用免费 Flex SDK 中的 mxmlc 编译了 Flex 内容。
这是我的 mxml 文件(我真的不知道我在用 mxml 做什么,所以请有人告诉我这种方法是否错误):(
CustomPreloader
是一个扩展mx 的简单类.preloaders.DownloadProgressBar
。)我喜欢这种方法的地方在于,我现在可以在 Flash 端做任何我喜欢做的事情;我可以不再担心导出哪些框架类。
我担心的一个问题是游戏现在运行速度可能会稍微慢一些。使用 SWFLoader 时是否存在性能问题?有更快速的替代方案吗?
In the end I just got fed up with all the mucking around in Flash, and decided to build the preloader (only) in Flex, embedding the game SWF in the preloader and loading it with SWFLoader. (This is based on Myk's suggestion.) I still get to have a single SWF at the end, with Flex's more robust preloading system handling the preloader display.
I didn't use the full Flex Builder in the end; I just compiled the Flex stuff with mxmlc from the free Flex SDK.
Here's my mxml file (I don't really know what I'm doing with mxml, so please someone tell me if this approach is wrong):
(
CustomPreloader
is a simple class that extendsmx.preloaders.DownloadProgressBar
.)What I like about this approach is that I can now do whatever I like over on the Flash side; I can stop worrying about what frame classes are exported on.
One concern I have is that the game possibly seems to be running slightly slower now. Are there performance issues when using SWFLoader? Is there a more speedy alternative?
为什么不简单地将您的资产放入您想要的框架中:
使用您的资源创建一个新类:
然后在 flash IDE 中创建一个新符号并使其扩展您的资源类,并将该符号放入您想要的框架中
Why not simply put your asset in the frame you want :
create a new class with your assets:
then in flash IDE create a new symbol and make it extends you Assets class, and put this symbol into the frame you want
我喜欢帕特里克的回答,听起来应该可行。
您也可以考虑在不同的 .swf 中编写预加载器 - 这非常简单,并且可以避免所有帧 1/帧 2 的废话。 :)
I like Patrick's answer, that sounds like it should work.
You might also consider just writing your preloader in a different .swf - it's pretty simple to do and you avoid all of that frame1/frame2 crap. :)