Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing SWF files using Transform SWF for Java from Flagstone

Tags:

java

flash

Has anyone successfully used the Transform SWF for Java library from [Flagstone Software][1]

[1]: http://www.flagstonesoftware.com/transform/index.html to edit an existing swf file. Mainly what I want to accomplish is load a swf file and replace images or texts dynamically. Thank you.

like image 752
mtanzania Avatar asked Jun 16 '26 17:06

mtanzania


1 Answers

I know it is a little bit late, but google searchers will still land here :-) This code will color the first text span of all text elements to red.

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.zip.DataFormatException;

import com.flagstone.transform.Movie;
import com.flagstone.transform.MovieTag;
import com.flagstone.transform.datatype.Color;
import com.flagstone.transform.text.DefineText;

public class Flash {
    public static void main(String args[]) throws MalformedURLException, DataFormatException, IOException {
        Movie m = new Movie();
        m.decodeFromFile(new File("C:\\tmp\\Movie.swf"));

        for (MovieTag mt : m.getObjects()) {
            System.out.println(mt.getClass() + "  " + mt.toString());
            if (mt instanceof DefineText) {
                ((DefineText) mt).getSpans().get(0).setColor(new Color(255, 0, 0));
            }
        }

        m.encodeToFile(new File("C:\\tmp\\foo.swf"));
    }
}
like image 64
KIC Avatar answered Jun 18 '26 08:06

KIC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!