The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SWF::Parser - Parse SWF file.

SYNOPSIS

  use SWF::Parser;

  $parser = SWF::Parser->new( 'header-callback' => \&header, 'tag-callback' => \&tag);
  # parse binary data
  $parser->parse( $data );
  # or parse SWF file
  $parser->parse_file( 'flash.swf' );

DESCRIPTION

SWF::Parser module provides a parser for SWF (Macromedia Flash(R)) file. It splits SWF into a header and tags and calls user subroutines.

METHODS

SWF::Parser->new( 'header-callback' => \&headersub, 'tag-callback' => \&tagsub [, stream => $stream, header => 'no'])

Creates a parser. The parser calls user subroutines when find SWF header and tags. You can set SWF::BinStream::Read object as the read stream. If not, internal stream is used. If you want to parse a tag block without SWF header, set header => 'no'.

&headersub( $self, $signature, $version, $length, $xmin, $ymin, $xmax, $ymax, $framerate, $framecount )

You should define a header-callback subroutine in your script. It is called with the following arguments:

  $self:       Parser object itself.
  $signature:  'FWS' for normal SWF and 'CWS' for compressed SWF.
  $version:    SWF version No.
  $length:     File length.
  $xmin, $ymin, $xmax, $ymax:
     Boundary rectangle size of frames, ($xmin,$ymin)-($xmax, $ymax), in TWIPS(1/20 pixels).
  $framerate:  The number of frames per seconds.
  $framecount: Total number of frames in the SWF.
&tagsub( $self, $tagno, $length, $datastream )

You should define a tag-callback subroutine in your script. It is called with the following arguments:

  $self:       Parser object itself.
  $tagno:      The ID number of the tag.
  $length:     Length of tag.
  $datastream: The SWF::BinStream::Read object that can be read the rest of tag data.
$parser->parse( $data )

parses the data block as a SWF. Can be called multiple times.

$parser->parse_file( $file );

parses a SWF file. The argument can be a filename or an already opened file handle.

$parser->parseheader;

parses a SWF header and calls &headersub. You don't need to call this method specifically because this method is usually called from parse method.

$parser->parsetag;

parses SWF tags and calls &tagsub. You don't need to call this method specifically because this method is usually called from parse method.

$parser->abort;

tells the parser to abort parsing.

COPYRIGHT

Copyright 2000 Yasuhiro Sasama (ySas), <ysas@nmt.ne.jp>

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

SEE ALSO

SWF::BinStream, SWF::Element

SWF file format specification from Macromedia.