setRate(24.0); $m->setDimension(320, 240); $m->setBackground(0xff, 0xff, 0xff); // functions with huge numbers of arbitrary // arguments are always a good idea! Really! function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string) { global $f, $m; $t = new SWFText(); $t->setFont($f); $t->setColor($r, $g, $b, $a); $t->setHeight(14); $t->moveTo(-($t->getWidth($string))/2, 32); //$f->getAscent()/2); $t->addString($string); // we can add properties just like a normal php var, // as long as the names aren't already used. // e.g., we can't set $i->scale, because that's a function $i = $m->add($t); $i->x = $x; $i->y = $y; $i->rot = $rot; $i->s = $scale; $i->rotateTo($rot); $i->scale($scale, $scale); // but the changes are local to the function, so we have to // return the changed object. kinda weird.. return $i; } function step($i) { $oldrot = $i->rot; $i->rot = 19*$i->rot/20; $i->x = (19*$i->x + 160)/20; $i->y = (19*$i->y + 120)/20; $i->s = (19*$i->s + 1.0)/20; $i->rotateTo($i->rot); $i->scaleTo($i->s, $i->s); $i->moveTo($i->x, $i->y); return $i; } // see? it sure paid off in legibility: $i1 = text(0xff, 0x33, 0x33, 0xff, 900, 160, 120, 0.03, $argv[0]); $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 160, 120, 0.04, $argv[0]); $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 160, 120, 0.001, $argv[0]); // (..that was sarcasm.) for($i=1; $i<=100; ++$i) { $i1 = step($i1); $i2 = step($i2); $i3 = step($i3); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?>