批量生成SWF文件

发布于 2025-01-08 02:37:30 字数 251 浏览 0 评论 0原文

我们需要生成大约 8,000 个几乎相同的 SWF 文件,但文本略有不同。我了解 flashvars,但不幸的是,我们无法控制这些文件的发布,也无法传入 flashvars。理想情况下,我正在寻找的是我们有一个 flash 设计师设计出一个漂亮的模板为我们提供文件中的占位符文本或元素。然后,我们可以多次调用命令行实用程序,以生成 8,000 个带有稍微修改的文本的副本。

我已经搜索了一整天,但没有找到任何可以帮助我们的东西。当然,我不是闪存开发人员,但这似乎非常简单。

We need to generate around 8,000 nearly identical SWF files with slightly different text. I know about flashvars, but unfortunately, we don't have control over the publishing of these files and can't have flashvars passed in. Ideally what I'm looking for is that we have a flash designer come up with a nice looking template for us with a placeholder text or element in the file. We can then call a command line utility many times to generate 8,000 copies of this with slightly modified text.

I've searched for an entire day now and haven't found anything to help us out. Granted, I'm not a flash developer, but it seems like this would be pretty straight-forward.

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

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

发布评论

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

评论(2

万人眼中万个我 2025-01-15 02:37:30

为什么 MXMLC 不起作用?

目标 SWF 格式是什么?如果是 8 及以下,您可以尝试将 MTASC 与 SWFMill 结合使用(它需要代码和图形的文本源文件)。

SWF规范是开放的,有多种解析器可以对SWF文件进行不同程度的分析。如果只是替换文本字段的内容,那么可能只需要重写包含文本字段的一个标记并更新文件头中的总文件大小即可。

如果您需要实时执行此操作,这实际上取决于您的 SWF 包含的代码量以及需要重新编译的代码量,但通常 Haxe 编译器比 MXMLC 快得多,并且对于小文件来说,它是可行的根据请求编译它们,而不是预编译所有它们并按需提供(取决于哪个更昂贵、编译所需的时间或服务器上的空间)。

编辑:比如说,你想使用 MXMLC,你可以有这样的东西:

#!/usr/bin/env bash

for i in {0..8000}
do
    cp ./ClassWithText.template ./ClassWithText.as
    sed -i s/%pattern%/counter${i}/g ./ClassWithText.as
    mxmlc ./ClassWithText.as -o ./result-${i}.swf
done

注意:你可能无法让 mxmlc 全局可访问,因为它有一些硬编码路径,所以,你会使用编译器的绝对路径,但思路应该是一样的。

然后,假设您在 ClassWithText.template 文件中有此文本:

var myText:String = "%pattern%";

它将被转换为:

var myText:String = "counter0";

然后编译“counter1”,然后编译等等。

Why won't MXMLC work?

What is the target SWF format? If it's 8 and below, you could try MTASC in combination with SWFMill (it takes text source files for code and graphics).

SWF spec is open, there are several parsers that can analyze the SWF file to different degree. If it's only a matter of replacing the content of a text field, then probably, it would take only as much as rewriting one tag that contains the text field and updating the total file size in the file header.

If you need to do that in real time, this will really depend on amount of code your SWF contains and how much of it needs to be recompiled, but generally Haxe compiler is much faster then MXMLC, and for small files it can be feasible to compile them upon request, rather then pre-compile all of them and serve on demand (depends on what is more expensive, the time it takes to compile, or the space on the server).

EDIT: say, you wanted to use MXMLC, you could have something like this:

#!/usr/bin/env bash

for i in {0..8000}
do
    cp ./ClassWithText.template ./ClassWithText.as
    sed -i s/%pattern%/counter${i}/g ./ClassWithText.as
    mxmlc ./ClassWithText.as -o ./result-${i}.swf
done

NOTE: you wouldn't probably be able to get mxmlc globally accessible because it has some hardcoded paths, so, you'd use an absolute path to the compiler, but the idea should be the same.

Then, say, you had this text in the ClassWithText.template file:

var myText:String = "%pattern%";

it would be transformed into:

var myText:String = "counter0";

and then compiled, "counter1", and then compiled and so on.

梦亿 2025-01-15 02:37:30

正如 wvxvw 所说,您可以使用 mxmlc 编译器 和另一种可能性正在使用 JSFL

As wvxvw says, you could use the mxmlc compiler and another possibility is scripting the Flash IDE using JSFL.

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