|
|
 |
LXV. Ming functions for Flash| 警告 | 本扩展模块是实验性的。该模块的行为,包括其函数的名称以及其它任何关于此模块的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。我们提醒您在使用本扩展模块的同时自担风险。
|
First of all: Ming is not an acronym. 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.
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@opaque.net.
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: http://ming.sourceforge.net/
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.
例子 1. built into PHP (Unix)
mkdir <phpdir>/ext/ming
cp php_ext/* <phpdir>/ext/ming
cd <phpdir>
./buildconf
./configure --with-ming <other config options>
|
Build and install PHP as usual,
restart web server if necessary.
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.
由于这些常量是由该扩展模块定义的,因此只有在该扩展模块被编译到 PHP 中,或者在运行时被动态加载后,这些常量才有效。
由于这些类是由该扩展模块定义的,因此它们仅在该扩展模块被编译到 PHP 内核中,或者在运行时被动态加载后才有效。
Ming introduces 13 new objects in PHP, all with matching methods and
attributes. To use them, you need to know about
objects.
- swfshape
- swffill
- swfgradient
- swfbitmap
- swftext
- swftextfield
- swffont
- swfdisplayitem
- swfmovie
- swfbutton
- swfaction
- swfmorph
- swfsprite
add a note
User Contributed Notes
Ming functions for Flash
ivv_rousse at yahoo dot com
04-Aug-2001 09: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('http://www.php.net/',
'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();
?>
| |