Transform SWF

Transform is an Open Source framework for reading and writing Flash (.swf) and Flash Video (.flv) files. The API gives you complete control over how files are created with access to all the features supported by the Flash Player but yet is still intuitive and easy to use.

Key Features

  • Full support for Flash 7, with Flash 9 coming soon.
  • Access to all of Flash giving full control of the Player.
  • Generate Flash files for any version of the desktop Flash Player.
  • Generate Flash Lite files for mobile phones and devices.
  • Easy to use API allows you to edit any flash file.
  • Comprehensive 2-D API to draw shapes from arbitrary complex paths.
  • Use OpenType or TrueType fonts to display text.
  • Direct support for generating images using JPEG, PNG and BMP files.
  • Add Event and streaming sounds from WAV and MP3 files.
  • Plugin architecture for adding decoders for new image and sound formats.
  • Java JDK integration adds support for AWT Fonts and ImageIO readers.
  • Open Source, BSD licence is free for commercial use.

An Example

Here is an example, in Java, showing how to use Transform to generate a flash file that displays a text field. For more examples, detailed information on Flash concepts and How-Tos take a look at the Cookbook.

import java.awt.Font;
import java.io.IOException;
import com.flagstone.transform.*;
import com.flagstone.transform.util.*;

int width = 6000;
int height = 1000;
int border = 400;
int fontSize = 240;

try {
    FSMovie movie = new FSMovie();

    Font font = new Font("Arial", Font.PLAIN, 1);
    String txt = "The quick, brown, fox jumped over the lazy dog.";
    char[] characters = txt.toCharArray();
    java.util.Arrays.sort(characters);

    FSTextConstructor constructor = new FSTextConstructor(
        movie.newIdentifier(), font);
    constructor.willDisplay(characters);

    FSDefineFont2 definition = constructor.defineFont();
    FSDefineText2 text = constructor.defineText(         movie.newIdentifier(), txt, fontSize, new FSColor(0,0,0));

    movie.setFrameSize(new FSBounds(-border, -border, width, height));
    movie.setFrameRate(1.0f);
    movie.add(new FSSetBackgroundColor(FSColorTable.lightblue()));
    movie.add(definition);
    movie.add(text);
    movie.add(new FSPlaceObject2(text.getIdentifier(), 1, 0 , 0));
    movie.add(new FSShowFrame());

    movie.encodeToFile("example.swf");
}
catch (IOException e) {
    System.err.println("Cannot write to file");
}