setDimension(550,400); $movie->setBackground(rand(0,0xFF),rand(0,0xFF),rand(0,0xFF)); $movie->setRate(31); function buttonSprite($string){ $font="ArialBlack.fdb"; $f = new SWFFont($font); $t = new SWFText(); $t->setFont($f); $t->setColor(0xff, 0x33, 0x33); $t->setHeight(20); $t->setSpacing(1.0); $t->addString($string); $sp = new SWFSprite(); $i = $sp->add($t); $sp->nextframe(); return $sp; } // make video controls // =& rather than just = to use reference rather than copy... better? $stop=&buttonSprite("stop"); $f1=$movie->add($stop); $f1->setname("mcstop"); $f1->moveto(140,220); $play=&buttonSprite("play"); $f1=$movie->add($play); $f1->setname("mcplay"); $f1->moveto(200,220); // prevframe is exported for actionscript $prevframe=&buttonSprite("prevframe"); $movie->addExport($prevframe, 'mcprevframe'); $movie->writeExports(); // actionscript to control playback using video control buttons // this code is on root in this movie but when this movie // is imported using SWFPrebuiltClip it will be inside a // clip and not on root so we need to use relative references // to clips not _root.mcstop... $strAction=" mcstop.onPress=function(){ stop(); }; mcplay.onPress=function(){ play(); }; "; $movie->add(new SWFAction($strAction)); // add flv to movie $flv=fopen("$flvpath/counter.flv", "rb"); $stream = new SWFVideoStream($flv); $m1=$movie->add($stream); $m1->moveto(240,150); for($i = 0; $i < $stream->getNumFrames(); $i++) { $movie->nextFrame(); } echo $i; // save swf with same name as filename $swfname = basename(__FILE__,".php"); $movie->save("$swfname.swf",9); ?>