tags:

views:

911

answers:

8

We've got dozens of versions of an SWF modified for different customers of a big Flash project, and now would have to replace some strings embedded in scripts in each copy. The FLA file for some of these is very difficult to locate or even missing (I inherited this mess and refactoring it is currently not an option).

Is there a (free) tool to replace strings used inside ActionScript? I tried swfmill to convert the files to XML and back but it can't handle international characters contained in the strings so I could get them only partially converted. Most of the strings were correctly extracted so another tool might do the job.

A: 

tricky - it might not be any easier, but you could load the 'locked' swf into one you control, then spider through its objects until you hit TextBox, using some for...in loops - it'd be a long, arduous process to map them out then change them, especially if the previous developer didn't name things in a helpful way, but if it's a fairly simple .swf then it might be too bad...

Also, there's a mac-only utility for decompiling swfs that I remember a coworker swearing by, but I don't recall the name... anybody?

matt lohkamp
+1  A: 

Well the only advice I can come up with is to fix swfmill to support international characters. You might want to ask in swfmill mailing list ([email protected] as far as I know) for a best way how to do it, shouldn't be too difficult if you know C/C++ a bit.

Michael Pliskin
A: 

Tough one - have you tried the Sothink decompiler? If that doesn't work, I'd say try loading the the swf into another swf, then drill down and change the content of the textfield - something like _root.loadedswf.clip1.box2.textField.text = "New text"; Obviously, this might not work if the application is complex.

Iain
+1  A: 

You could try Burak's URL Action Editor -- it says URL, but I'm pretty sure it lets you edit any text in a SWF. I haven't used it, but I have used his ActionScript Viewer, which works wonderfully.

davr
A: 

If the files are using actionscript 2 maybe you can disassemble and reassemble using http://flasm.sourceforge.net/ (And of course: modify the strings before reassembling). For as3 adobe provides a decompiler that might be usable to achieve the same, but I don't think your flash will be as3 if you've inherited it.

A: 

How about this one? http://code.google.com/p/swfreplacer/wiki/Intro

A: 

It seems to me that swfmill has updated their tool to support international characters, at least for Latvian language (which requires UTF-8). Strings are encoded as HTML entities.

Solved some similar problems with legacy swf file.

Papuass
+1  A: 

You can use Apparat for this kind of task. It allows you to alter ActionScript 3 bytecode in SWF and SWC files.

I would prefer the Scala source branch for your task. Basically the code would look like this:

val swf = Swf from "in.swf"
for(tag <- swf.tags) {
  (Abc fromTag tag) match {
    case Some(abc) => {
      val strings = abc.cpool.strings
      for(i <- 1 until strings.length) {
        if(strings(i) == 'search) {
          strings(i) = 'replacement
        }
      }
      abc write tag
    }
    case None =>
}
swf write "out.swf"
Joa Ebert
I got an apparat.abc.AbcOutputStream.writeU30 when it tries to write replaced string. Can you help?
barbuza
Did you use the code I posted?
Joa Ebert