5 kinds of PHP generated swf file code

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags *.h file animation classic code example file files flash animation

5 php tutorials generate swf file code
/ *
Here are a few php generated flash file code is generated from a simple swf file to generate flash animation files, each instance is a classic.
* /
// First open the 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 text move text.php
<? php
$ f = new swffont ('_sans');

$ pt = new swftextfield ();
$ pt-> setfont ($ f);
$ pt-> setcolor (0, 0, 0);
$ pt-> setheight (400);
$ pt-> 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-> 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 three: draw some simple graphics draw a straight 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: Rotate the 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-> moveto (150, 150);

for ($ i = 0; $ i <100; $ i ++) {
$ ts-> rotate (10);
$ m-> nextframe ();
}

$ m-> save ('rotate.swf');
?>
************************************************** *************************
Example five:
Use pictures

Text and simple vector graphics such as lines, circles, arcs, curves, and rectangles are great, but in the ideal world you must have access to the images in these flash animations. Fortunately, the ming library makes it easy to work with images, 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');

Related Article

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.