AS3 将外部文件打包成一个独立的.swf
我创建了一个非常大型的 Flash 游戏,并且显然存在重大疏忽 - 希望托管我的游戏的 Flash 门户网站需要将其放在一个独立的 .swf 中。但是,问题是我从外部加载所有内容。我从 .plist 文件加载关卡数据,从 .png 文件加载图像,从 .wav 加载声音,所有这些都位于 .swf 目录中的文件夹中。它们通过 Loader 和 URLRequest 加载。
有什么方法可以嵌入这些,以便它可以独立运行吗?最好是比单独编写嵌入行更简单的方法,因为有数千个文件。
非常感谢!
I've created a very large scale Flash game and have apparently had a massive oversight - the flash portal websites wishing to host my game need it in one stand alone .swf. However, the problem is I load everything externally. I load the level data from .plist files, the images from .png and the sound from .wav, all located in folders in the .swf directory. They're loaded through Loader's and URLRequest.
Is there any way I can embed these so it will run as a stand alone? Preferably an easier way than individually writing embed lines, as there are 1000s of files.
Thanks very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短回答:否。
详细回答:因为您使用 Loaders 和 URLRequests,所以每个资产都需要作为外部请求进行访问。您要求一种简单的方法让它们指向 SWF 中的资源,但这是不可能的。但是,如果您稍微改变一下工作流程,您可能会找到一种在代码更改方面可以接受的方法,并且从长远来看将使您受益。
如果您使用 Flash Builder、FDT、FlashDevelop 或 IntelliJ 等编辑器,您应该探索 SWC 文件的多种用途。您可以在 Flash IDE 的发布设置中点击“导出为 SWC”复选标记,这将在您每次测试 (Cmd+Enter) fla 文件时创建一个 SWC。您可以在您选择的编辑器中导入该 SWC 文件,并将原始 fla 文件的任何符号引用为 AS3 类。编译时,Flash 编译器将获取您的原始资源并将其嵌入到生成的 SWF 中,然后您可以将其分发到您喜欢的任何门户网站。 PNG 和 WAV 是最简单的,对于 .plist,您必须使用
[Embed(...)]
元标记。拥有一个 SWF 的另一个好处是您无需预加载每个单独的资源,并且所有资源创建都在一个线程中完成。不再需要事件侦听器来加载资源!确保为符号和链接属性正确命名以使用 SWC。您可以使用标准包格式轻松找到您的资源,例如命名符号
fla.icons.GreyLogo
或fla.homepage.BackgroundGraphic
。 获取徽标如果您有正确的
import fla.icons.GreyLogo
方向,您可以通过调用这里有一篇文章对此进行了更彻底的介绍。 如果我正确理解您的设置,这将是大量工作,但它可能结果发现以便在以后的项目中占据优势。干杯,
EP。
Short answer: No.
Long answer: Because you use Loaders and URLRequests, every asset needs to be accessed as an external request. You ask for a simple way to have them point to assets inside your SWF, which is not possible. However, if you change your workflow a bit, you might find a way that is acceptible in terms of code changes, and will benefit you in the long run.
If you use an editor like Flash Builder, FDT, FlashDevelop or IntelliJ, you should explore the many uses of SWC files. You can hit the 'export as SWC' checkmark in the Flash IDE's publish settings, which will create a SWC every time you test (Cmd+Enter) the fla file. You can import that SWC file in your editor of choice, and reference any symbols of your original fla file as AS3 classes. On compile, the flash compiler will take your original assets and embed them into the resulting SWF, that you can then distribute to any portal website you like. PNGs and WAVs are the easiest, for .plist you'll have to use the
[Embed(...)]
meta tag. Benefits next to having one SWF are also that you don't need to preload each separate asset and that all asset creation is done in one thread. No more event listener spaghetti for loading assets!Make sure you name your symbols and linkage properties appropriately for using SWCs. You can use the standard package format to easily find your assets, like naming a symbol
fla.icons.GreyLogo
orfla.homepage.BackgroundGraphic
. If you then have the correctimport fla.icons.GreyLogo
direction in place, you can get at the logo by callingHere is an article that goes into this a little more thorougly. It will be a lot of work if I understand your setup correctly, but it might turn out to be advantageous in future projects.
Cheers,
EP.