#!/usr/bin/perl

use Flash;
use CGI;

my $q = new CGI;
print $q->header(-type=>'application/x-shockwave-flash');

my $framerate = 30;

my $word = $q->param('text');
my $type = $q->param('type');
$word = "default" if (! defined($word) || $word =~ /^\s*$/);
my $pi = 3.141592654;

my @letters = split //, $word;



my $filename = '-'; #'/tmp/'.time(). {}. rand(). $$;
openswf($filename,519,231,$framerate);
        
        
# --- just to init colors
mul_colour(1,1,1,1);
add_colour(0,0,0,0);

ortho2(-100,100,-100,100);


# --- define an image
my $bitmapid = nextid();
define_bitmap($bitmapid,"yapc.gif");
my $nid = rect_image($bitmapid);
push_matrix;
  translate(0,0,-100);
  scale(0.2,0.4,0.2);
  place_object($nid,00);
pop_matrix;

show_frame;

# --- define a font
define_font(nextid(),"Pix3");
font_size(25);
font_slant(0);

my $offset = nextid();
for ($j=0; $j<scalar(@letters); $j++) {
  define_text(nextid(),$letters[$j],1);
}


my $sep = (2*$pi)/(scalar(@letters));

for ($i=0;$i<=(30*$pi); $i++) {
  
  for ($j=0; $j<=scalar(@letters); $j++)
  {
     remove_object($j+10);
     my $x = sin($i/15 +($j * $sep)) * 40;
     my $y = cos($i/15 +($j * $sep)) * 80;
     
     push_matrix;        
        add_colour(0.1,0.1,0.1,-(0.6));
        rotate(($i*$pi*180)/30, 'y') if ($type==1);
        translate($x,$y,0);                
        rotate(($i*$pi*180)/30, 'y') if (!defined($type) ||$type!=1);
        place_object($j+$offset,$j+10);
     pop_matrix;   
  
  }
  show_frame;

}


closeswf();
print STDERR "Got here\n";

#open IN, "$filename";
#while (<IN>) { print; }
#close IN;

#unlink $filename;

exit 0;




syntax highlighted by