package SWF::Generator; use strict; use SWF; use vars qw(@ISA $VERSION); @ISA = qw(SWF); $VERSION = .1; my $debug = 1; sub new { # Usage: my $swf = SWF::Generator->new; # my $outSWF = SWF::Generator->new($inSWF); # # If $inSWF is a SWF::Parser object, will do the right thing. my $class = shift; $class = ref($class) || $class; my $inSWF = shift; print STDERR " SWF::Generator - Debug mode on.\n\n" if $debug; my $self = $class->SUPER::new(); # read in the SWF::Parser object if it's there if (defined $inSWF) { $self->version($inSWF->version); $self->fileLength($inSWF->fileLength); $self->frameSize($inSWF->frameSize); $self->frameRate($inSWF->frameRate); $self->frameCount($inSWF->frameCount); } return $self; } sub generate { my $self = shift; print STDERR "Generating the SWF...\n" if $debug; $self->gHeader; print $self->content; } # # Here's some generation routines to get started... # sub gHeader { my $self = shift; $self->content("FWS"); $self->{content} .= pack("C", $self->version); $self->{content} .= pack("L", $self->fileLength); my $rect = $self->frameSize; $self->{content} .= $rect->write; my ($fore, $aft) = split /\./, $self->frameRate; $self->{content} .= pack("C", $aft); $self->{content} .= pack("C", $fore); $self->{content} .= pack("S", $self->frameCount); } 1;