在编译时将数据注入 swf
是否可以在编译时在 swf 中注入数据,例如资产集合(视频、图像...)?
我们有一个 Flex 应用程序,需要能够在运行时导出包含所有必要数据的 swf,因为它需要作为独立应用程序运行(在线和离线)。
到目前为止的想法是创建一个服务器端脚本来调用 Flex 编译器并向其提供所需的数据。对于单个文件使用 [Embed] 标记,这种方法似乎工作得很好,但是当尝试为每个导出的 swf 注入长度不同的数据集合时,它会变得有点混乱。
我们可以为每个资产生成一个包含一个嵌入变量的 mxml 文件,并在编译时包含它,但这种方法似乎不太理想。
我们研究了一些动作脚本字节码库,但它们似乎不适合这个。
对于此类问题有什么建议或其他方法吗?
谢谢,
伯特
Is it possible to inject data, for example a collection of assets (video, images...), in an swf at compile time?
We have a flex application that needs to be able to export an swf at runtime that contains all the necessary data, because it needs to run as a standalone application (on- and offline).
The idea so far was to create a server side script that calls the flex compiler and feed it the data it needs. This approach seems to work fine using the [Embed] tag for single files, but it gets kind of messy when trying to inject collections of data that vary in length for each exported swf.
We could generate an mxml file with one embedded variable for each asset and include it at compile time, but that approach seems for from ideal.
We've looked into some actionscript bytecode libraries, but those do not seem to be fit for this.
Any suggestions or other approaches for this kind of problem?
Thx,
Bert
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
[Embed]
绝对是最佳选择。您可以生成包含大量嵌入的 AS 文件。虽然生成的代码可能有点难看,但您也可以生成更好的 api。例如,如果您想要一个数组,请生成如下代码:这样,唯一的丑陋之处在于只有代码生成器才能看到的私有变量。公共变量是一个数组。
[Embed]
is definitely the way to go. You can generate an AS file that has lots of embeds. While the generated code might be a bit ugly, you can generate a nicer api too. For example, if you want an array, generate code like this:That way the only ugliness is in private variables only the code generator will see. The public variable is an array.
我不知道为什么你需要这样做,但我想我会尝试从模板或类似的东西生成所需的动作脚本文件,然后调用 Flex 编译器。
希望这对您有帮助...
I'm not sure why you need to do that but i guess i'll try to generate the needed actionscript file from template or something like that and then call the flex compiler.
Hope this helps you...
尝试as3swf
它能够从空的
ByteArray据我所知,可以在那里插入嵌入式图形
try as3swf
it is able to generate an swf file from an empty
ByteArray
and afaik it's possible to insert embedded graphics there就像 Sam 所说,[嵌入] 可以工作,但你想加载什么?我的第一反应是,为每个请求重新编译会对服务器造成很大的拖累。
Like Sam said, [Embed] could work, but what are you trying to load? My first reaction is that recompiling for every request would be a big drag on the server.