The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


SWF::File - Create SWF file.


  use SWF::File;

  $swf = SWF::File->new('movie.swf', Version => 4);
  # set header data
  $swf->FrameSize( 0, 0, 1000, 1000);
  # set tags
  $tag = SWF::Element::Tag->new( .... )
  # save SWF and close


SWF::File module can be used to make SWF (Macromedia Flash(R)) movie. SWF::File is a subclass of SWF::BinStream::Write, so you can pack SWF::Element::Tags in it.


SWF::File->new( [$filename, [Version => $version, FrameRate => $framerate, FrameSize => [$x1, $y1, $x2, $y2]]] )

Creates a new SWF file. You can set SWF header parameters.

NOTE: Unlike the previous version, SWF version can be set only here. Default is 5.

$swf->FrameRate( [$framerate] )

Sets and gets the frame rate of the movie (frames per second). Default is 12.

$swf->FrameSize( [$x1, $y1, $x2, $y2] )

Sets the bounding box size of the movie frame in TWIPs (1 TWIP = 1/20 pixel), and gets the size as SWF::Element::RECT object. Default is (0, 0, 12800, 9600).

$swf->FrameCount( [$count] )

Sets and gets the frame count of the movie. Usually you don't need to set because SWF::File object automatically count the ShowFrame tags. If you want to set the different value, you should set it just before $swf->close.


Makes output SWF compressed. You should set the version to 6 or higher before call it.

$swf->close( [$filename] ) / $swf->save( [$filename] )

Saves SWF to the file and closes it.


Copyright 2001 Yasuhiro Sasama (ySas), <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


SWF::BinStream, SWF::Element

SWF file format specification from Macromedia.