Take the 2-minute tour ×

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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}
    cp ./ClassWithText.template ./ClassWithText.as
    sed -i s/%pattern%/counter${i}/g ./ClassWithText.as
    mxmlc ./ClassWithText.as -o ./result-${i}.swf

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.

share|improve this answer
Is MXMLC something that most flash developers are familiar with? As I said, I know literally nothing about flash, but do know that we need 8000 physical SWF files with slightly differing text. I'm reading up on the docs for MXMLC, but without knowing anything about flash development, it's pretty foreign. Will be contacting flash developers tomorrow in our area, but want to make sure I know what I'm looking for before I do so. –  Kevin Feb 24 '12 at 2:50
Thanks for the answer and example. I'll try to find someone who can help us out with this. –  Kevin Feb 24 '12 at 15:57

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

share|improve this answer

Your Answer


