从 Flash 库加载位图
好的!!我构建了一个游戏,它从外部源(而不是从库)获取tileSheet(位图图像)和一些xml 文件。事实证明,如果我想在大多数网站上发布我的游戏,这是一个坏主意。因为大多数网站只允许我加载单个文件。现在,我需要找到一个替代方案。
我尝试做跨域的事情,但这很痛苦,因为我遇到了一些安全问题,我不知道如何解决。我针对该问题单独发表了一篇文章,其中包含我的代码。但现在我需要知道是否还有更好的希望。
也许我可以从库中加载位图图像,这是有道理的。如果有人知道怎么做,请分享。但是xml情况呢?说到这一点,我是不是已经完蛋了?是否不可能构建一个从单个文件读取 xml 文件和位图图像的游戏?
OK!! I built a game that grabs a tileSheet (bitmap image) and some xml files from an outside source (not from the library). Turns out that this is a bad idea if I want to post my game on most sites. Cause majority sites only give me ability to load a single file. NOW, I need to figure an alternative.
I tried doing the cross-domain thing but that is a pain cause I am running into some security issues in which I do not know how to get by. I made a seperate post for that issue, with my code in it. But now I need to know if there is some better hope.
It makes sense that maybe I could load a bitmap image from the library. If anyone know's how then please do so share. But What about the xml situation ?? am I pretty much screwed when it comes to that ?? Is it impossible to build a game that reads an xml file and bitmap images from a single file ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是在谈论在 .swf 文件中嵌入图像和一些 XML 吗?我相信这需要 mxmlc。
对于图像 (AS3):
对于某些 XML (AS3):
Are you talking about embedding an image and some XML within your .swf file? This requires mxmlc, I believe.
For an image (AS3):
For some XML (AS3):
您想要将图像和 XML 文件嵌入到 SWF 中。
您需要使用 Flex SDK 附带的 mxmlc。
详细信息:在您的 SWF 中嵌入几乎所有内容,< a href="http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html" rel="nofollow noreferrer">Adobe Flex 3 帮助:嵌入资源类型
编辑: 将 Flex SDK 与 Flash CS4 结合使用< /a> 描述如何设置 Flash CS4,以便您可以使用
Embed
标记等 Flex 功能。我认为 CS3 没有同等功能;您需要手动或使用外部 IDE(例如 FlashDevelopYou want to embed the images and XML file in the SWF.
You'll need to use mxmlc, which comes with the Flex SDK.
More info: Embed Almost Anything in Your SWF, Adobe Flex 3 Help: Embedding Asset Types
Edit: Using the Flex SDK with Flash CS4 describes how to set up Flash CS4 so you can use Flex features like the
Embed
tag. I don't think CS3 has an equivalent feature; you'll need to do the compiling manually or with an external IDE like FlashDevelop in that case.在您的另一篇文章中,我提到了使用 SWC
您可以将位图和图像放入导出为 SWC 的 Flash 文件中。您只需调用该类即可创建这些对象。
是的,您必须加载以后需要使用的所有图像,因此如果您的游戏有 50 个级别,并且大多数用户只需要前 20 个级别中使用的图像,则您将需要加载所有图像。尽管有一种方法可以解决这个问题,但它相当复杂。
这些 SWC 的另一个好处是,您可以拥有 20 个 SWC,每个 SWC 持有不同的资产,并在需要时调用它们。例如,我有一个包含所有组件的 SWC 库。 Flex 编译器将仅推送最终 swf 中所需的内容,因此,如果 SWC 中有未使用的资源,它们不会不必要地使您的文件膨胀。
您还会发现很多库现在都以 SWC 格式提供,例如 google API。
In your other post I referred to using SWCs
You can put your bitmaps and images in the flash file that you export as an swc. and you can create these objects just by calling the class.
Yes, you will have to load all the images you need to use down the road so if you have a game with 50 levels, and most users only need the images used in the first 20, you will need to load all. Although there is a way of going around that, it's quite complicated.
The other nice thing about these SWCs is that you can have 20 of them, each holding different assets and call them when you want. For example I've got a swc library that holds all the components. The flex compiler will push only the contents you need in the final swf, so if you have assets in the SWCs that you're not using, they won't bloat your file needlessly.
You will also find that a lot of libraries are now available in swc format, like the google API.