|
|
LIX. Ming functions for FlashAten��o | Este m�dulo �
EXPERIMENTAL. Isso quer dizer que o comportamento destas fun��es
e seus nomes, incluindo TUDO o que est� documentado aqui
pode mudar em futuras vers�es do PHP, SEM QUALQUER NOTIFICA��O.
Esteja avisado, e use este m�dulo por sua pr�pria conta e
risco. |
Ming is an open-source (LGPL) library which allows you to create SWF
("Flash") format movies. Ming supports almost all of Flash 4's features,
including: shapes, gradients, bitmaps (pngs and jpegs), morphs ("shape
tweens"), text, buttons, actions, sprites ("movie clips"), streaming mp3,
and color transforms--the only thing that's missing is sound events.
Ming is not an acronym.
Note that all values specifying length, distance, size, etc. are in "twips",
twenty units per pixel. That's pretty much arbitrary, though, since the player
scales the movie to whatever pixel size is specified in the embed/object tag,
or the entire frame if not embedded.
Ming offers a number of advantages over the existing PHP/libswf module.
You can use Ming anywhere you can compile the code, whereas libswf is
closed-source and only available for a few platforms, Windows not one of
them. Ming provides some insulation from the mundane details of the SWF
file format, wrapping the movie elements in PHP objects. Also, Ming is
still being maintained; if there's a feature that you want to see, just
let us know .
Ming was added in PHP 4.0.5.
To use Ming with PHP, you first need to build and install the Ming
library. Source code and installation instructions are available at the
Ming home page :
along with examples, a small tutorial, and the latest news.
Download the ming archive. Unpack the archive. Go in the
Ming directory. make. make install.
This will build libming.so and install it
into /usr/lib/, and copy
ming.h into /usr/include/.
Edit the PREFIX= line in the
Makefile to change the installation directory.
Build and install php as usual,
Restart web server if necessary
download php_ming.so.gz.
uncompress it and copy it to your php modules directory.
(you can find your php module directory by running
php-config --extension-dir).
Now either just add extension=php_ming.so
to your php.ini file, or put
dl('php_ming.so'); at the head of all of your
Ming scripts.
Ming introduces 13 new objects in PHP, all with matching methods and
attributes. To use them, you need to know about
objects.
User Contributed Notes Ming functions for Flash |
|
04-Aug-2001 12:17 |
|
// Simple button with link
<?php
Ming_setScale(1.0);
function makeRect($r, $g, $b){
$s = new SWFShape();
$s->setRightFill($s->addFill($r, $g, $b));
$s->movePenTo(-100,-20);
$s->drawLineTo(100,-20);
$s->drawLineTo(100,20);
$s->drawLineTo(-100,20);
$s->drawLineTo(-100,-20);
return $s;
}
// Set Font
$font = new SWFFont("test.fdb");
$text1 = new SWFText();
$text1->setFont($font);
$text1->moveTo(155, 410);
$text1->setColor(0x00, 0x00, 0x00);
$text1->setHeight(28);
$text1->addString("php.net");
$b1 = new SWFButton();
$b1->setUp(makeRect(0xff, 0, 0));
$b1->setOver(makeRect(0xcc, 0, 0));
$b1->setDown(makeRect(0, 0, 0xaa));
$b1->setHit(makeRect(0, 0, 0));
$b1->addAction(new SWFAction("getURL('
'phpsite');"),
SWFBUTTON_MOUSEUP);
$m = new SWFMovie();
$m->setDimension(1000,1000);
$m->setBackground(0xcc, 0xcc, 0xcc);
$i = $m->add($b1);
$m->add($text1);
$i->setName("phpsite");
$i->moveTo(200,400);
header("Content-type: application/x-shockwave-flash");
$m->output();
?>
|
|
20-Aug-2001 06:50 |
|
//In quicktime, movies may be exported as jpeg or png
//This object will convert any movie that has been saved as a group of
images into
//an swf file. The frame rate and other attributes can be controlled
$path = "my_movie_dir"; //relative path to the jpg/png or bmp
files
$frame_rate=30; //frame rate of the flash movie
$quality=50; //image quality during conversion (only valid if not jpeg)
$skip_rate=5; //how many frames to skip
set_time_limit("600"); //this could take some time
$converter=new images_to_swf($path,$frame_rate,$skip_rate);
//$converter->convert_images(70); //Use this if using non jpeg files or
decreasing the quality
$converter->make_movie();//Make the movie
//Do two things with it
$converter->save_movie("my_movie_dir/my_movie.swf");
$converter->output_movie();
class images_to_swf {
var $path; //path to the image files
var $skip_rate;
var $movie;
var $images=array();
function images_to_swf($path,$frame_rate=30,$skip_rate=5) {
$this->path=$path;
$this->skip_rate=$skip_rate;
$this->movie=new swfmovie ();
$this->movie->setrate ($frame_rate);
}
function convert_images($quality=80,$delete_old_files=1) {
$main = opendir($this->path);
rewinddir($main);
//first convert to jpeg (if we have to)
//also change the quality
while($filename = readdir($main)) {
//only use valid file types
if (ereg("(png|bmp|jpg|jpeg)\$",$filename)) {
$file_path=$this->path."/".$filename;
if (ereg("png\$",$filename)) $temp_img=imagecreatefrompng
($file_path);
else if (ereg("bmp\$",$filename))
$temp_img=imagecreatefrompng ($file_path);
else if (ereg("(jpg|jpeg)\$",$filename))
$temp_img=imagecreatefromjpeg ($file_path);
if (ereg("(png|bmp)\$",$filename)) {
if ($delete_old_files) unlink($file_path);
$new_file_path=$file_path.".jpg";
}
else $new_file_path=$file_path;
ImageJPEG($temp_img,$new_file_path,$quality);
//echo "Converted $filename to $new_file_path at quality
$quality<br />";
}
}
}
function make_movie() {
$main = opendir($this->path);
rewinddir($main);
//Get all valid jpegs
while($filename = readdir($main)) {
if (ereg("(jpg|jpeg)\$",$filename)) {
$file_path=$this->path."/".$filename;
$valid_paths[]=$file_path;
}
}
//Put jpegs in order
sort($valid_paths);
//then create the movie
for ($a=0; $a<count($valid_paths); $a=$a+$this->skip_rate) {
$fp = fopen($valid_paths[$a],"rb");
$this->images[$a] = fread($fp,999999);
fclose($fp);
$this->movie->add(new swfbitmap($this->images[$a]));
$this->movie->nextframe();
//echo "Added ".$valid_paths[$a]." to the movie<br
/>\n";
}
}
function save_movie($file_name) {
$this->movie->save($file_name);
}
function output_movie() {
header('Content-type: application/x-shockwave-flash');
$this->movie->output();
}
}
|
|
26-Dec-2001 03:42 |
|
You can get several .fdb font files from
|
|
ceoATl-i-eDOTcom
20-Apr-2002 09:15 |
|
Like, the build instructions are for building from CVS, I think...
Mere mortals can just do:
cd ming-x.y.z (xyz is version)
make static
make install
ldconfig (you might need do use "whereis ldconfig" to find it,
and then use the full path)
cd ../php-x.y.z
./configure --with-ming ...
And don't be copying the "new" ming code into your PHP dir like
the ming instructions say to do. That will just mess you up.
|
|
|
| |