#!/usr/bin/perl -w my @tagdef = qw( End ShowFrame DefineShape FreeCharacter PlaceObject RemoveObject DefineBits DefineButton JPEGTables SetBackgroundColor DefineFont DefineText DoAction DefineFontInfo DefineSound StartSound DefineButtonSound SoundStreamHead SoundStreamBlock DefineBitsLossless DefineBitsJPEG2 DefineShape2 DefineButtonCxform Protect PlaceObject2 RemoveObject2 DefineShape3 DefineText2 DefineEditText DefineButton2 DefineBitsJPEG3 DefineBitsLossless2 DefineSprite NameCharacter FrameLabel SoundStreamHead2 DefineMorphShape DefineFont2 ShapeStyle ShapeRecord ButtonRecord TextRecord ); my %files; my %tags; my %filesize; my @filelist; #my @tagdef; my $colour; my $colour1 = "#c0c0c0"; my $colour2 = "#ffffff"; opendir (DIR,".") or die "Couldn't open directory : $!\n"; $colour = $colour1; while ($_ = readdir(DIR)) { next unless ((-f $_) && /.swf$/i); #next if ($_ eq "extract"); #next if ($_ =~ /^out/); print STDERR $`,"\n"; my $thisfile = $_; open (FILE, "./parsefiles $_|") or die "Couldn't parse $_ : $!\n"; push @filelist, $thisfile; #$filesize{$_} = (stat($thisfile))[7]; my $file = join "", ; #while () #{ # if (/tag([^\s]+)/ig) # { # push @tagdef, $1; # push @{$files{$thisfile}}, $1 unless grep(/$1/, @{$files{$thisfile}}); # push @{$tags{$1}}, $_ unless grep(/$thisfile/, @{$tags{$1}}); # } #} foreach my $tag (@tagdef) { if ($file =~ /$tag/) { push @{$files{$_}}, $tag; push @{$tags{$tag}}, $_; } } } print "Perl::Flash - developers\n"; print qq|\n|; print qq|
Perl::Flash

What's this all about then?
Well this page is for anybody wanting to test SWF applications they're writing. It's autogenerated by an ugly little Perl script I hacked up and, given a directory with some SWF files in, knocks up a few tables with all the files with a particular tag and all the tags in a particular file plus the least number of files you'll need to cover every tag and the smallest file for each tag.

The names of the SWF files are links to themselves and the names of tags are links to the appropraite section of the SWF File Reference on OpenSWF.org.

If you have any other good SWF files, especially any with tags that I don't have examples of already, then email them to me and I'll whack them up here.

And whilst you're here have a look at my Perl::Flash page </shameless plug>

Simon Wistow

|; print qq|

A list of every file and every tag in it...

\n|; print qq|\n|; foreach my $file (@filelist) { my $loccol = ($colour eq $colour1)? "#ffffff" : "#000000"; print qq|\t\n"; $colour = get_colour($colour); } print qq|
|; print "[".to_url($file)."]"; print qq||; foreach my $val (@{$files{$file}}) { print " ".to_tag($val)} print "
\n|; print qq|

A list of every tag and every file it appears in ...

\n|; my @toftp; $colour = $colour1; print qq||; foreach my $tag (@tagdef){ my $max = 0; my $file = ""; my $loccol = ($colour eq $colour1)? "#ffffff" : "#000000"; print qq|\t\n"; $colour = get_colour($colour); } print qq|
|; print "[".to_tag($tag)."]"; print qq||; foreach my $val (@{$tags{$tag}}) { print " ".to_url($val); my $score = scalar(@{$files{$val}}); if ($score > $max){ $file = $val ; $max = $score;} } #print "$file" if ($max>0); push @toftp, $file unless (grep (/$file/, @toftp)); print " 
\n|; print qq|

The minimum files you need to pass every tag (or at least every tag that I have in all my test SWFs) ..

\n|; my @got; foreach my $file(@toftp) { print to_url($file)."
\n"; } $colour = $colour1; print qq|

On the other hand those files above are pretty big and it is faster to parse smaller files so this list is the smallest file for each tag ...

\n|; @filelist = sort { (stat($a))[7] <=> (stat($b))[7] } @filelist; my @nowgot; print qq|\n|; foreach my $file (@filelist) { my $fileflag = 0; foreach my $tag (@{$files{$file}}) { unless (grep (/$tag/, @nowgot)) { unless ($fileflag) { my $loccol = ($colour eq $colour1)? "#ffffff" : "#000000"; print qq|\t" ; $colour = get_colour($colour); } print "\n"; } print qq|
|; my $size = (stat($file))[7]; my $sizestring = ($size>1024)?sprintf("%.0f k",$size/1024):"$size bytes"; print "[".to_url($file). "] (".$sizestring.")"; print qq| |; } print " ".to_tag($tag); $fileflag =1; } push @nowgot, $tag; } if ($fileflag) { print "
\n|; print ""; #print "Which will give you ...\n"; #@got = sort @got; #foreach my $tag (@got) #{ # print "$tag "; #} #print "\n"; sub to_url { my $file = shift; $file =~ /.swf$/i; return qq|$`|; } sub to_tag { my $loccol = ($colour eq $colour1)? "#ffffff" : "#000000"; my $tag = shift; my $uctag = uc($tag); return qq|$tag|; } sub get_colour { return ($_[0] eq $colour1)?$colour2:$colour1; } exit 0;