Five php tutorials generate swf File Code
/*
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-> addstring ('20140901 ');
$ 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 ');