/*
The following php flash file generation code is from simple SWF file generation to Flash Animation file generation. Each instance is classic.
*/
// First enable PHP extension php_ming
$ F = new swffont (_ sans );
$ T = new swftextfield ();
$ T-> setfont ($ F );
$ T-> setcolor (0, 0, 0 );
$ T-> setheight (400 );
$ T-> addstring (Hello world );
$ M = new swfmovie ();
$ M-> setdimension (2500,800 );
$ M-> Add ($ t );
$ M-> Save (hello.swf );
?>
**************************************** **************************************
Example 2: Let the text work. Text. php
<? PHP
$ F = new swffont (_ sans );
$ Pt = new swftextfield ();
$ Pt-> setfont ($ F );
$ Pt-> setcolor (0, 0, 0 );
$ Pt-& gt; setheight (400 );
$ Pt-& gt; addstring (1000 );
$ TT = new swftextfield ();
$ Tt-> setfont ($ F );
$ Tt-> setcolor (192,192,192, 90 );
$ Tt-> setheight (350 );
$ Tt-> addstring (points );
$ M = new swfmovie ();
$ M-> setdimension (2500,800 );
$ PTS = $ M-> Add ($ pt );
$ PTS-> moveTo (0, 0 );
$ TTS = $ M-> Add ($ TT );
$ TTS-& gt; moveTo (1300,200 );
For ($ I = 0; $ I <10; $ I ++ ){
$ M-> nextframe ();
$ PTS-> scaleto (1.0 + ($ I/10.0), 1.0 + ($ I/10.0 ));
}
$ M-> Save (text.swf );
?>
**************************************** *************************************
Example 3: draw some images and draw a simple line. php
<? PHP
$ M = new swfmovie ();
$ M-> setdimension (300,300 );
$ S = new swfshape ();
$ S-> setline (10, 0, 0, 0 );
$ S-> movepento (10, 10 );
$ S-> drawlineto (290,290 );
$ M-> Add ($ S );
$ M-> Save (line.swf );
?>
**************************************** **************************************
Example 4: rotating a straight line
<? PHP
$ M = new swfmovie ();
$ M-> setdimension (300,300 );
$ S = new swfshape ();
$ S-> setline (5, 0, 0, 0 );
$ S-> movepento (-100,-100 );
$ S-> drawlineto (100,100 );
$ Ts = $ M-> Add ($ S );
$ Ts-& gt; moveTo (150,150 );
For ($ I = 0; I I <100; $ I ++ ){
$ Ts-> rotate (10 );
$ M-> nextframe ();
}
$ M-> Save (rotate.swf );
?>
**************************************** ***********************************
Example 5:
Use Images
Text and simple vector graphics such as straight lines, circles, arcs, curves, and rectangles are excellent, but ideally you must be able to access the images in these flash animations. Fortunately, the Ming library allows you to use images easily, as shown below:
<? PHP
$ IMG = new swfbitmap (file_get_contents (megan.jpg ));
$ S = new swfshape ();
$ Imgf = $ S-> addfill ($ IMG );
$ S-> setrightfill ($ imgf );
$ S-> movepento (0, 0 );
$ S-> drawlineto ($ IMG-> getwidth (), 0 );
$ S-> drawlineto ($ IMG-> getwidth (), $ IMG-> getheight ());
$ S-> drawlineto (0, $ IMG-> getheight ());
$ S-> drawlineto (0, 0 );
$ M = new swfmovie ();
$ M-> setdimension ($ IMG-> getwidth () * 2, $ IMG-> getheight () * 2 );
$ Is = $ M-> Add ($ S );
$ Is-> moveTo ($ IMG-> getwidth ()/2, $ IMG-> getheight ()/2 );
For ($ I = 0; $ I <10; $ I ++)
{
$ Is-> skewx (0.02 );
$ Is-> skewy (-0.03 );
$ M-> nextframe ();
}
$ M-> Save (image.swf );