Main Contents

santanu create typewriter effect with ming php for flash (swf) movie

November 25th, 2005

This is nice and simple code it creates the simple effect which you might have seen in lots of web sites. As it is PHP you can use the same from your own news reader to database.

setBackground(0x00,0x00,0x00);// SM - This is very important as it set sets the speed of the movie// SM - Higher the number fater the typing will appear$movie->setRate(3);// SM - This one will depends upon you$movie->setDimension(600,40);$movie->setFrames(31);$movie->nextFrame();// Define your String here  $str = 'V enky is rich and very busy man ...';  /*  SM - As you note The space between character if not fixed  SM - due to font width so you have to figure out your own  SM - Now we split our string and make an array with the same  */  $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);//  print_r($chars);$inc = 0 ;for($i=0;$isetFont($myFont);       $myText->setColor(255,255,255);       $myText->SetHeight(30);       $myText->addString($chars[$i]);       echo ("$chars[$i] \n") ;       $firstText=$movie->add($myText);       $firstText->moveTo($inc,30);       $inc = $inc + 18;       // SM - this is very critical as you need to add this extra frame to make this effectof some typer       $movie->nextframe();       // SM - This helps to determine the width of the movie       // SM - turn only if you need the same       // echo "inc is $inc \n" ;       }       // SM - we do not want to loop this movie//       $movie->add(new SWFAction("stop();"));       // SM - Save the movie       $movie->save("/tmp/banner.swf",9);?>

  Tech Notes    

Leave a Reply


Feed