
Generation Flash on the web - server in PHP
Usually at creation of flash-rollers it is meant, that they are made, and then and are placed on a site. Practically always, so it also is. But in fact the Internet assumes a certain interactivity. And it is valid, in flash there is an opportunity of the description of reactions to the certain actions of the user. But, at the same time, the volume of a file increases, programming considerably becomes complicated. And in fact as it would be convenient, that flash-rollers were generated directly on a site proceeding
From the certain conditions.
You think, it is impossible? On the contrary, similar means exist. The most widespread and, probably, while the best is a library ming for generation of animation in a format .swf from scripts perl, php and python.
One of vital issues which arises at many who starts to use the given library in job, that she is at present insufficiently documentary, also is turned out necessary examples of use while a little. Well and eventually - the library though is distributed in initial codes, but exist a little various sborok which work a little differently. In general, a product, though also perspective, but still, to tell the truth, rather "crude".
There is one more problem. The matter is that the library is written under linux. It, basically, correctly. The majority of webs - servers work in linux. But very much often there is a situation when it is desirable to test the scripts using ming under windows. In fact very few people uses linux houses or at job, the operational system from microsoft is more habitual nevertheless. So for many webs - developers use windows with established apache became standard, where spend all necessary " field jobs " before finally to lay out ready result on the web - server.
For the beginning, before to describe installation and adjustment to the given library, we shall name sites where it is possible to take all necessary components. php including for windows, naturally, undertake on http://www.php.net/, versions for developers, including any additional libraries (including especially important php_ming.dll) are accessible on http://www.php4win.com/. Initial texts of the library can be taken on a site of group of developers - www.opaque.net/ming.
Now about adjustment apache and php. It is known, that php under apache it is possible to put in two ways: as the interpreter and as the module. To use ming, the second is necessary. It is necessary to establish two libraries. It php4ts.dll and php4apache.dll.
If apache it is established in c:apache we shall place libraries in the catalogue appropriate to them c:apachemodules. Then it is necessary to specify about it in adjustments of the web - server in a file httpd.conf. It will be necessary to add only one line to a file:
loadmodule php4_module modules/php4apache.dll
And then to specify, that files with expansions php,
phtml, php3, php4 and phps should be processed php. It is necessary for this purpose
To add the next lines in httpd.conf:
addtype application/x-httpd-php .php
addtype application/x-httpd-php .phtml
addtype application/x-httpd-php .php3
addtype application/x-httpd-php .php4
addtype application/x-httpd-php-source .phps
Also, that our web - server "knew", that index files can be now not only index.htm *, we find directoryindex directive and is finished new types of files:
directoryindex index.html index.shtml index.htm
index.phtml index.php index.php3 index.php4
Now we are checked. We start apache. If at you windows 95 or apache it is started in a console window (not as service) you will see such line:
apache/1.3.22 (win32) php/4.0.6 running...
It means, that that's all right and it is time to start directly installation of library ming. It will be necessary to establish library php_ming.dll and to bring in respective alterations to a file php.ini.
In php.ini we find and it is changeable the next lines:
; directory in which the loadable extensions
(modules) reside.
extension_dir=c:apachephpext
This directive specifies a way for search of libraries with expansions by the interpreter php. In the same catalogue the file php_ming.dll is placed also.
After that we add in a configuration file sleduhhuju a line:
extension=php_ming.dll
Now, if all is made correctly, after start apache, it is possible to place in a file with a php-script phpinfo command (). In result in a browser it will be possible to find out the information on the established library:
ming ming swf output library the funk in your
trunk
version 0.1.0
Now, when the library is established, it is high time to understand, how her to use. The elementary example of a script which generates a flash-roller:
<? php
$s = new swfshape ();
$s-> setline (4, 0x7f, 0, 0);
$s-> setrightfill ($s-> addfill (0xff, 0,
0));
$s-> movepento (10, 10);
$s-> drawlineto (310, 10);
$s-> drawlineto (310, Shirokov);
$s-> drawcurveto (10, Shirokov, 10, 10);
$m = new swfmovie ();
$m-> setdimension (320, 240);
$m-> setrate (12.0);
$m-> add ($s);
$m-> nextframe ();
header (' content-type:
application/x-shockwave-flash ');
$m-> output ();
?>
The description of functions with which help it is possible to generate flash, it is possible to find both on a site http://www.opaque.net/ming, and together with initial texts in library. It is necessary - to study one them and to use. In result you can generate flash directly on the web - server and to make necessary changes to files in case of need.