|
|
 |
LXXX. Ming functions for Flash| Aviso | Esta extensión es
EXPERIMENTAL. Esto significa que el
comportamiento de esta extensión, los nombre de sus funciones y
en definitiva TODO lo documentado sobre esta extensión, puede
cambiar en una futura versión de PHP SIN AVISO. La advertencia
queda hecha, y utilizar esta extensión queda bajo su propia
responsabilidad. |
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.
Ejemplo 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.
Esta extensión no tiene directivas de
configuración en php.ini. Estas constantes están
definidas por esta extensión y estarán disponibles
solamente cuando la extensión ha sido o bien compilada dentro
de PHP o grabada dinámicamente en tiempo de ejecución.
Estas clases están
definidas por esta extensión y estarán disponibles
cuando la extensión haya sido compilada dentro de PHP o cargada
dinámicamente en tiempo de ejecución
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
- Tabla de contenidos
- SWFButton::addASound -- Associates a sound with a button transition
- SWFButton::setMenu -- enable track as menu button behaviour
- SWFDisplayItem::addAction -- Adds this SWFAction to the given SWFSprite instance
- SWFDisplayItem::endMask -- Another way of defining a MASK layer
- SWFDisplayItem::getRot --
- SWFDisplayItem::getX --
- SWFDisplayItem::getXScale --
- SWFDisplayItem::getXSkew --
- SWFDisplayItem::getY --
- SWFDisplayItem::getYScale --
- SWFDisplayItem::getYSkew --
- SWFDisplayItem::setMaskLevel -- Defines a MASK layer at level
- SWFDisplayItem::setMatrix -- Sets the item's transform matrix
- SWFFont::getAscent -- Returns the ascent of the font, or 0 if not available
- SWFFont::getDescent -- Returns the descent of the font, or 0 if not available
- SWFFont::getLeading -- Returns the leading of the font, or 0 if not available
- SWFFont::getShape -- Returns the glyph shape of a char as a text string
- SWFFont::getUTF8Width -- Calculates the width of the given string in this font at full height
- SWFFontChar::addChars -- Adds characters to a font for exporting font
- SWFFontChar::addUTF8Chars -- Adds characters to a font for exporting font
- SWFMovie::addExport --
- SWFMovie::addFont --
- SWFMovie::importChar --
- SWFMovie::importFont --
- SWFMovie::labelFrame -- Labels frame
- SWFMovie::saveToFile --
- SWFMovie::startSound --
- SWFMovie::stopSound --
- SWFMovie::writeExports --
- SWFPrebuiltClip -- Returns a SWFPrebuiltClip object
- SWFShape::drawArc -- Draws an arc of radius r centered at the current location, from angle startAngle to angle endAngle measured clockwise from 12 o'clock
- SWFShape::drawCircle -- Draws a circle of radius r centered at the current location, in a counter-clockwise fashion
- SWFShape::drawCubic -- Draws a cubic bezier curve using the current position and the three given points as control points
- SWFShape::drawCubicTo -- Draws a cubic bezier curve using the current position and the three given points as control points
- SWFShape::drawGlyph -- Draws the first character in the given string into the shape using the glyph definition from the given font
- SWFSound -- Returns a new SWFSound object from given file
- SWFSoundInstance::loopCount --
- SWFSoundInstance::loopInPoint --
- SWFSoundInstance::loopOutPoint --
- SWFSoundInstance::noMultiple --
- SWFSprite::labelFrame -- Labels frame
- SWFSprite::startSound --
- SWFSprite::stopSound --
- SWFText::addUTF8String -- Writes the given text into this SWFText object at the current pen position,
using the current font, height, spacing, and color
- SWFText::getAscent -- Returns the ascent of the current font at its current size, or 0 if not available
- SWFText::getDescent -- Returns the descent of the current font at its current size, or 0 if not available
- SWFText::getLeading -- Returns the leading of the current font at its current size, or 0 if not available
- SWFText::getUTF8Width -- calculates the width of the given string in this text objects current font and size
- SWFTextField::addChars -- adds characters to a font that will be available within a textfield
- SWFTextField::setPadding -- Sets the padding of this textfield
- SWFVideoStream::getNumFrames --
- SWFVideoStream::setDimension --
- SWFVideoStream -- Returns a SWFVideoStream object
- ming_keypress -- Returns the action flag for keyPress(char)
- ming_setcubicthreshold --
Set cubic threshold (?)
- ming_setscale --
Set scale (?)
- ming_useConstants -- Use constant pool (?)
- ming_useswfversion --
Use SWF version (?)
- SWFAction -- Creates a new Action
- SWFBitmap->getHeight -- Returns the bitmap's height
- SWFBitmap->getWidth -- Returns the bitmap's width
- SWFBitmap -- Loads Bitmap object
- SWFbutton->addAction -- Adds an action
- SWFbutton->addShape -- Adds a shape to a button
- SWFbutton->setAction -- Sets the action
- SWFbutton->setdown -- Alias for addShape(shape, SWFBUTTON_DOWN)
- SWFbutton->setHit -- Alias for addShape(shape, SWFBUTTON_HIT)
- SWFbutton->setOver -- Alias for addShape(shape, SWFBUTTON_OVER)
- SWFbutton->setUp -- Alias for addShape(shape, SWFBUTTON_UP)
- SWFbutton -- Creates a new Button
- SWFDisplayItem->addColor -- Adds the given color to this item's color transform
- SWFDisplayItem->move -- Moves object in relative coordinates
- SWFDisplayItem->moveTo -- Moves object in global coordinates
- SWFDisplayItem->multColor -- Multiplies the item's color transform
- SWFDisplayItem->remove -- Removes the object from the movie
- SWFDisplayItem->Rotate -- Rotates in relative coordinates
- SWFDisplayItem->rotateTo -- Rotates the object in global coordinates
- SWFDisplayItem->scale -- Scales the object in relative coordinates
- SWFDisplayItem->scaleTo -- Scales the object in global coordinates
- SWFDisplayItem->setDepth -- Sets z-order
- SWFDisplayItem->setName -- Sets the object's name
- SWFDisplayItem->setRatio -- Sets the object's ratio
- SWFDisplayItem->skewX -- Sets the X-skew
- SWFDisplayItem->skewXTo -- Sets the X-skew
- SWFDisplayItem->skewY -- Sets the Y-skew
- SWFDisplayItem->skewYTo -- Sets the Y-skew
- SWFFill->moveTo -- Moves fill origin
- SWFFill->rotateTo -- Sets fill's rotation
- SWFFill->scaleTo -- Sets fill's scale
- SWFFill->skewXTo -- Sets fill x-skew
- SWFFill->skewYTo -- Sets fill y-skew
- SWFFill -- Loads SWFFill object
- swffont->getwidth -- Returns the string's width
- SWFFont -- Loads a font definition
- SWFGradient->addEntry -- Adds an entry to the gradient list
- SWFGradient -- Creates a gradient object
- SWFMorph->getshape1 -- Gets a handle to the starting shape
- SWFMorph->getshape2 -- Gets a handle to the ending shape
- SWFMorph -- Creates a new SWFMorph object
- SWFMovie->add -- Adds any type of data to a movie
- SWFMovie->nextframe -- Moves to the next frame of the animation
- SWFMovie->output -- Dumps your lovingly prepared movie out
- swfmovie->remove -- Removes the object instance from the display list
- SWFMovie->save -- Saves your movie in a file
- SWFMovie->setbackground -- Sets the background color
- SWFMovie->setdimension -- Sets the movie's width and height
- SWFMovie->setframes -- Sets the total number of frames in the animation
- SWFMovie->setrate -- Sets the animation's frame rate
- SWFMovie->streammp3 -- Streams a MP3 file
- SWFMovie -- Creates a new movie object, representing an SWF version 4 movie
- SWFShape->addFill -- Adds a solid fill to the shape
- SWFShape->drawCurve -- Draws a curve (relative)
- SWFShape->drawCurveTo -- Draws a curve
- SWFShape->drawLine -- Draws a line (relative)
- SWFShape->drawLineTo -- Draws a line
- SWFShape->movePen -- Moves the shape's pen (relative)
- SWFShape->movePenTo -- Moves the shape's pen
- SWFShape->setLeftFill -- Sets left rasterizing color
- SWFShape->setLine -- Sets the shape's line style
- SWFShape->setRightFill -- Sets right rasterizing color
- SWFShape -- Creates a new shape object
- swfsprite->add -- Adds an object to a sprite
- SWFSprite->nextframe -- Moves to the next frame of the animation
- SWFSprite->remove -- Removes an object to a sprite
- SWFSprite->setframes -- Sets the total number of frames in the animation
- SWFSprite -- Creates a movie clip (a sprite)
- SWFText->addString -- Draws a string
- SWFText->getWidth -- Computes string's width
- SWFText->moveTo -- Moves the pen
- SWFText->setColor -- Sets the current font color
- SWFText->setFont -- Sets the current font
- SWFText->setHeight -- Sets the current font height
- SWFText->setSpacing -- Sets the current font spacing
- SWFText -- Creates a new SWFText object
- SWFTextField->addstring -- Concatenates the given string to the text field
- SWFTextField->align -- Sets the text field alignment
- SWFTextField->setbounds -- Sets the text field width and height
- SWFTextField->setcolor -- Sets the color of the text field
- SWFTextField->setFont -- Sets the text field font
- SWFTextField->setHeight -- Sets the font height of this text field font
- SWFTextField->setindentation -- Sets the indentation of the first line
- SWFTextField->setLeftMargin -- Sets the left margin width of the text field
- SWFTextField->setLineSpacing -- Sets the line spacing of the text field
- SWFTextField->setMargins -- Sets the margins width of the text field
- SWFTextField->setname -- Sets the variable name
- SWFTextField->setrightMargin -- Sets the right margin width of the text field
- SWFTextField -- Creates a text field object
add a note
User Contributed Notes
Ming functions for Flash
Scottie_Too_Hottie7 at lycos dot com
11-Nov-2005 12:59
For People Like My Mate, Matt, Who Dosent Know Much PHP, I Am Creating A Simpeler PHP Libary. It Runs Under Ming 0.3
It - Along With Two Examples - Can Be Currently Downloaded From The Link Below
PLEASE NOTE : At The Time Of This Post, The Libary Is Currently Is Unfinished And Currently Looks Like A Mess Of Files - But It Works!
http://members.lycos.co.uk/cgming/simpleswf.html
dank at nospam dot org
08-Apr-2005 02:23
/*
If you are looking to do some simple interaction between Flash MX and php,
here is an extremely basic model to get you started. The Flash file has a simple
Input Text field which allows the user to enter text (ie a textbox). The flash
then passes the textfield to the php script for processing/database interaction etc.
The idea is a form made in Flash, but processing by php/mysql (or whatever). If you want
to handle all GUI in Flash, see the links below for more info.
All "Actions" or "Action Script" located in frame 1, layer 1.
In Flash, create an Input Box with an instance name of myTextBox.
Create a "submit button" using Insert>New Symbol>Movie Clip.
Dont use the PushButton Component or you will have to add
scripting to that component (ie outside Frame1 Layer1). Keeping all the
Action Script in Frame1 makes for a simpler example.
Next, click on the background in Frame1 (the "Properties" dialog
should show the Background color). Hit F9 to show actions for Frame1.
Enter the below code:
*/
//Create object to hold vars
dataSender = new LoadVars();
//Define submit button behavior
submit_button.onRelease = function() {
//assign properties to LoadVars object created previously
//myTextBox is instance name for input text box
//foo will be the var passed to php (ie $foo)
//Set foo to the text entered by user
dataSender.foo = myTextBox.text;
//Call flash's send function to send foo to the php script
//Using "_self" will pass control to the php script
dataSender.send("testFlash.php", "_self", "POST");
}
/* Put the swf file in an html file and upload it to the server
Create the below php file and save it as testFlash.php:
<?php
echo "foo= $foo";
?>
Push testFlash.php to the same directory on the server and hit
your html file with your browser.
Parts of this code taken from:
http://www.thegoldenmean.com/technique/flashMX_mailform1.html
and
http://actionscript-toolbox.com/samplemx_php.php
*/
wokan at cox dot net
01-Jun-2004 06:07
For those who don't get the naming, _Ming_ the Merciless was comic book hero _Flash_ Gordon's arch enemy.
gaz_b3 at yahoo dot com
04-Apr-2003 05:11
The current CVS version, Ming 0.3a, supports
a lot of MX ActionScript including the MX Drawing API.
This is very nice for easy command line compiling of
MX ActionScript only movies.
For example:
<?
ming_setScale(20.00000000);
ming_useswfversion(6);
$movie = new SWFMovie();
$movie->setDimension(550,400);
$movie->setBackground(0xcc, 0xcc, 0xcc );
$movie->setRate(31);
$strAction = "
_root.createEmptyMovieClip ( 'triangle', 1 );
with ( _root.triangle ) {
lineStyle( 5, 0xff00ff, 100 );
moveTo( 200, 200 );
lineTo( 300,300 );
lineTo( 100, 300 );
lineTo( 200, 200 );
}
";
$movie->add(new SWFAction( str_replace("\r", "", $strAction) ));
$movie->save("trianglemx.swf");
?>
Lots of examples here:
http://www16.brinkster.com/gazb/ming/
kunnoichi at hotmail dot com
20-Aug-2001 12: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();
}
}
ivv_rousse at yahoo dot com
04-Aug-2001 06: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;
}
$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();
?>
| |
|
| Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos |  | Cake Mania Jugadores: 6835 Categoría del juego: Acción Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero. |
|  | Rainbow Web Jugadores: 2199 Categoría del juego: Puzzles Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente. |
|  | Mahjongg Fortuna Jugadores: 12462 Categoría del juego: Solitarios Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta. |
|  | Chainz 2 Jugadores: 6955 Categoría del juego: Puzzles Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más. |
|  | Delicious Jugadores: 4405 Categoría del juego: Acción Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues! |
|  | Bookworm Jugadores: 4568 Categoría del juego: Palabras Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos! |
|  | Zuma Jugadores: 4976 Categoría del juego: Acción Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás! |
|  | Jewel of Atlantis Jugadores: 3798 Categoría del juego: Puzzles Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis. |
|  | Jewel Quest Jugadores: 3727 Categoría del juego: Puzzles Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos! |
|  | Bejeweled 2 Jugadores: 3659 Categoría del juego: Puzzles Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca. |
|
|