Five php methods to generate swf file code

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-> 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 ');

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.