LI. Ming functions for Flash


This module is EXPERIMENTAL. That means, that the behaviour of these functions, these function names, in concreto ANYTHING documented here can change in a future release of PHP WITHOUT NOTICE. Be warned, and use this module at your own risk.


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 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.

built into php (unix)

       mkdir <phpdir>/ext/ming 
       cp php_ext/* <phpdir>/ext/ming 
       cd <phpdir>
       ./configure --with-ming <other config options>


Build and install php as usual, Restart web server if necessary

built into php (unix)

download 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 to your php.ini file, or put dl(''); at the head of all of your Ming scripts.

How to use Ming

Ming introduces 13 new object in PHP, all with matching methods and attributes. To use them, you need to know about objects.

Table of Contents
SWFMovie -- Creates a new movie object, representing an SWF version 4 movie.
SWFMovie->output -- Dumps your lovingly prepared movie out.
SWFMovie->save -- Saves your movie in a file.
SWFMovie->add -- Adds any type of data to a movie.
SWFMovie->remove -- Removes the object instance from the display list.
SWFMovie->setbackground -- Sets the background color.
SWFMovie->setrate -- Sets the animation's frame rate.
SWFMovie->setdimension -- Sets the movie's width and height.
SWFMovie->setframes -- Sets the total number of frames in the animation.
SWFMovie->nextframe -- Moves to the next frame of the animation.
SWFMovie->streammp3 -- Streams a MP3 file.
SWFDisplayItem -- Creates a new displayitem object.
SWFDisplayItem->moveTo -- Moves object in global coordinates.
SWFDisplayItem->move -- Moves object in relative coordinates.
SWFDisplayItem->scaleTo -- Scales the object in global coordinates.
SWFDisplayItem->scale -- Scales the object in relative coordinates.
SWFDisplayItem->rotateTo -- Rotates the object in global coordinates.
SWFDisplayItem->Rotate -- Rotates in relative coordinates.
SWFDisplayItem->skewXTo -- Sets the X-skew.
SWFDisplayItem->skewX -- Sets the X-skew.
SWFDisplayItem->skewYTo -- Sets the Y-skew.
SWFDisplayItem->skewY -- Sets the Y-skew.
SWFDisplayItem->setDepth -- Sets z-order
SWFDisplayItem->remove -- Removes the object from the movie
SWFDisplayItem->setName -- Sets the object's name
SWFDisplayItem->setRatio -- Sets the object's ratio.
SWFDisplayItem->addColor -- Adds the given color to this item's color transform.
SWFDisplayItem->multColor -- Multiplies the item's color transform.
SWFShape -- Creates a new shape object.
SWFShape->setLine -- Sets the shape's line style.
SWFShape->addFill -- Adds a solid fill to the shape.
SWFShape->setLeftFill -- Sets left rasterizing color.
SWFShape->setRightFill -- Sets right rasterizing color.
SWFShape->movePenTo -- Moves the shape's pen.
SWFShape->movePen -- Moves the shape's pen (relative).
SWFShape->drawLineTo -- Draws a line.
SWFShape->drawLine -- Draws a line (relative).
SWFShape->drawCurveTo -- Draws a curve.
SWFShape->drawCurve -- Draws a curve (relative).
SWFGradient -- Creates a gradient object
SWFGradient->addEntry -- Adds an entry to the gradient list.
SWFBitmap -- Loads Bitmap object
SWFBitmap->getWidth -- Returns the bitmap's width.
SWFBitmap->getHeight -- Returns the bitmap's height.
SWFFill -- Loads SWFFill object
SWFFill->moveTo -- Moves fill origin
SWFFill->scaleTo -- Sets fill's scale
SWFFill->rotateTo -- Sets fill's rotation
SWFFill->skewXTo -- Sets fill x-skew
SWFFill->skewYTo -- Sets fill y-skew
SWFMorph -- Creates a new SWFMorph object.
SWFMorph->getshape1 -- Gets a handle to the starting shape
SWFMorph->getshape2 -- Gets a handle to the ending shape
SWFText -- Creates a new SWFText object.
SWFText->setFont -- Sets the current font
SWFText->setHeight -- Sets the current font height
SWFText->setSpacing -- Sets the current font spacing
SWFText->setColor -- Sets the current font color
SWFText->moveTo -- Moves the pen
SWFText->addString -- Draws a string
SWFText->getWidth -- Computes string's width
SWFFont -- Loads a font definition
swffont->getwidth -- Returns the string's width
SWFTextField -- Creates a text field object
SWFTextField->setFont -- Sets the text field font
SWFTextField->setbounds -- Sets the text field width and height
SWFTextField->align -- Sets the text field alignment
SWFTextField->setHeight -- Sets the font height of this text field font.
SWFTextField->setLeftMargin -- Sets the left margin width of the text field.
SWFTextField->setrightMargin -- Sets the right margin width of the text field.
SWFTextField->setMargins -- Sets the margins width of the text field.
SWFTextField->setindentation -- Sets the indentation of the first line.
SWFTextField->setLineSpacing -- Sets the line spacing of the text field.
SWFTextField->setcolor -- Sets the color of the text field.
SWFTextField->setname -- Sets the variable name
SWFTextField->addstring -- Concatenates the given string to the text field
SWFSprite -- Creates a movie clip (a sprite)
SWFSprite->add -- Adds an object to a sprite
SWFSprite->remove -- Removes an object to a sprite
SWFSprite->setframes -- Sets the total number of frames in the animation.
SWFSprite->nextframe -- Moves to the next frame of the animation.
SWFbutton -- Creates a new Button.
SWFbutton->addShape -- Adds a shape to a button
SWFbutton->setUp -- Alias for addShape(shape, SWFBUTTON_UP)
SWFbutton->setOver -- Alias for addShape(shape, SWFBUTTON_OVER)
SWFbutton->setdown -- Alias for addShape(shape, SWFBUTTON_DOWN))
SWFbutton->setHit -- Alias for addShape(shape, SWFBUTTON_HIT)
SWFbutton->addAction -- Adds an action
SWFbutton->setAction -- Sets the action
SWFAction -- Creates a new Action.