#!/usr/bin/perl -w
use strict;
use SWF
::Constants qw(:Fill
);
use CGI;
my $query = new CGI;
my $string = $query->param('string') || "todbot";
my $width=320;
my $height=240;
my $m = new SWF::Movie();
$m->setDimension($width,$height);
$m->setBackground(0x00, 0x00, 0x00);
$m->add(new SWF::Action("
//_quality = 'LOW';
frames._visible = false;
sparks = [];
"));
my $g = new SWF::Gradient();
$g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
$g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
$g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
$g->addEntry(1.0, 0xff, 0xff, 0xff, 0);
# gradient shape thing
my $s = new SWF::Shape();
my $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
$f->scaleTo(0.03);
$s->setRightFill($f);
$s->movePenTo(-30, -30);
$s->drawLine(60, 0);
$s->drawLine(0, 60);
$s->drawLine(-60, 0);
$s->drawLine(0, -60);
my $font = new SWF::Font("fonts/test.fdb");
my $text = new SWF::Text();
$text->setFont($font);
$text->setColor(0x0,0x0,0x0);
$text->setHeight(10);
$text->addString($string);
# need to make this a sprite so we can multColor it
my $p = new SWF::Sprite();
$p->add($s);
my $texti = $p->add($text);
$texti->move( $text->getWidth($string)/2 - $text->getWidth($string), 0 );
$p->nextFrame();
# put the shape in here, each frame a different color
my $q = new SWF::Sprite();
$q->add(new SWF::Action("gotoFrame(random(7)+1); stop();"));
my $i = $q->add($p);
$i->multColor(1.0, 1.0, 1.0);
$q->nextFrame();
$i->multColor(1.0, 0.5, 0.5);
$q->nextFrame();
$i->multColor(1.0, 0.75, 0.5);
$q->nextFrame();
$i->multColor(1.0, 1.0, 0.5);
$q->nextFrame();
$i->multColor(0.5, 1.0, 0.5);
$q->nextFrame();
$i->multColor(0.5, 0.5, 1.0);
$q->nextFrame();
$i->multColor(1.0, 0.5, 1.0);
$q->nextFrame();
# finally, this one contains the action code
$p = new SWF::Sprite();
$i = $p->add($q);
$i->setName('frames');
$p->add(new SWF::Action("
dx = _root.dx/3 + random(10)-5;
dy = _root.dy/3;
x = (_root._xmouse<=0) ? $width/2 : _root._xmouse;
y = (_root._ymouse<=0) ? $height/2 : _root._ymouse;
alpha = 100;
"));
$p->nextFrame();
$p->add(new SWF::Action("
this._x = x;
this._y = y;
this._alpha = alpha;
x += dx;
y += dy;
dy += 3;
alpha -= 8;
"));
$p->nextFrame();
$p->add(new SWF::Action("prevFrame(); play();"));
$p->nextFrame();
$i = $m->add($p);
$i->setName('frames');
$m->nextFrame();
$m->add(new SWF::Action("
dx = _xmouse - lastx;
dy = _ymouse - lasty;
lastx = _xmouse;
lasty = _ymouse;
if(++num == 11)
num = 1;
if(sparks[num])
removeMovieClip(sparks[num]);
duplicateMovieClip('frames', 'char'+num, num);
sparks[num] = this['char'+num];
"));
$m->nextFrame();
$m->add(new SWF::Action("prevFrame(); play();"));
print "Content-type: application/x-shockwave-flash\n\n";
$m->output();