Five PHP code for generating SWF files

Source: Internet
Author: User

/*
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.