## swftoperl - a flash to ming-perl converter.

Based on Daves swftophp. Tested only on a Linuxbox (SuSE 7.2). Would like to hear from success with other OS/versions. Peter Liscovius

### Story:

I started from swftophp-source, converted this to a swftoperl and made some changes/enhancements, because swftophp and the util-stuff wasn't updated for a while.

The aim is to provide a program that can take a flash 3/4/5/? file and convert it to a ming-perl script that produces the same or a better/smaller flashfile with the same behavior without the need to change anything.

### Install:

Start a console, go to the $ming/util/ - directory and type `make swftoperl`

Now swftoperl should be build from c-source in the same directory. (i hope successful.)

Type `swftoperl` to test. It should tell you something like `Give me a filename.`

### Usage:

`swftoperl myflash.swf`

To save the script to a file, go to a console and type

`swftoperl myflash.swf >myflash.pl` or
`swftoperl /home/peter/myflash.swf >/home/peter/myflash.pl` or
`swftoperl ~/myflash.swf >~/myflash.pl`

myflash.swf is the name of your flashfile.

Some additional informations will be maybe printed to STDERR, so you don't have the ugly text in your myflash.pl , but you know about it.

Works this in the same way under Windows?

### Changes:

- Working currently on fixing TextField features. Simply remove constants with a number like SWFTEXTFIELD_2. I try to find out the meaning of unexplained bits. (What position is SWFTEXTFIELD_HTML)? Heared about SWFTEXTFIELD_USEFONT. Which bit? Look at #defines before function `void printTextField(FILE *f, int length){}` in swftoperl.c
- `SWF::Shape->setMaskLevel(depth)` included. Enables masks using shapes. (depth-1) is the number of the following objects(shapes,movieclips,..) that will maybe added at the same movie or movieclip.

      $maskshape_i = $movie->add($maskshape);
      $maskshape_i->setMaskLevel(2);
      $shapeA_i = $movie->add($shapeA);
      $shapeB_i = $movie->add($shapeB);

  This will only mask the instance of `$shapeA` (depth=2), but not `$shapeB`-instance (depth=3).

- Change "Sprite" to "MovieClip".

### Todo:

Also look at file TODO

Much, much. But some things must be first done in ming/ming-perl itself.

Here is a list of todos:

- Text
- TextField and FONT. Uses only builtin "Browserfonts", not the font i wanted. I read there must be a constant SWFTEXTFIELD_USEFONT but i don't find it in the ming-source (0.2a). Example?
- DefineFont2
- command line options like
  --out=filename.pl STDOUT
  --writefonts=yes / no
  --fontdir=.
  --overwritefonts=yes / no
  --writeBitmaps=yes / no if yes both filetypes are yes
  --writeJPEG=yes / no
  --writeGIF=yes / no
  --writeSound=yes / no if yes both filetypes are yes
  --writeMP3=yes / no
  --writeWAV=yes / no
  --minglibdir= (default: an example in a perlcomment)

  Bold words are the default values.

- Actionscript should work without extra modifications.
- There are differences between F4 and F5 Actionscript. When you want to read x-property of `object`: in FLASH 4 `object.x`, but in Flash5 `object._x`. So `SWF::setVersion(4/5)` is important.
- `use SWF();` should automatically only import the used modules and CONSTANTS. Really needed?