LXXXVII. Ming pour Flash

Avertissement

Ce module est EXPERIMENTAL. Cela signifie que le comportement de ces fonctions, leurs noms et, concrètement, TOUT ce qui est documenté ici peut changer dans un futur proche, SANS PREAVIS ! Soyez-en conscient, et utilisez ce module à vos risques et périls.

Introduction

Avant tout, sachez que Ming n'est pas un acronyme. Ming est une bibliothèque open-source (LGPL) qui vous permet de créer des animations au format Flash. Ming supporte toutes les fonctionnalités de Flash 4 : les formes (shapes), les gradients, les images bitmaps (JPEG et PNG), les morphing (transformations d'une forme en une autre), les textes, actions, sprites (mini animations), le streaming MP3 et les transformations de couleurs. Le seul ajout futur est celui des événements sons.

Notez que toutes les distances spécifiées (longueurs, distances, tailles...) sont en "twips", c'est-à-dire 20 unités par pixels. C'est plus ou moins arbitraire, car le lecteur Flash fait une mise à l'échelle avec les valeurs qui lui sont fournies dans la balise embed, ou la frame courante si la balise embed n'est pas utilisée.

Ming propose de nombreux avantages par rapport à l'extension swf. Vous pouvez utiliser Ming sur tous les OS où vous pouvez compiler le code, tandis que swf est limité à Windows. Ming vous évite la déconcertante complexité du format SWF, en transformant les éléments des animations en objets PHP. Enfin, Ming est toujours en cours de développement et surveillé par son auteur : si vous souhaitez une nouvelle fonctionnalité, dites-le nous : http://ming.sourceforge.net/

Ming et tous les objets cités ont été ajoutés en PHP 4.0.5.

Pré-requis

Pour utiliser Ming avec PHP, vous devez d'abord installer la librairy Ming. Le code source et les instructions d'installation sont disponibles sur la page d'accueil de Ming : http://ming.sourceforge.net/, avec des exemples un tutorial et l'actualité Ming.

Téléchargez l'archive Ming. Décompressez-la et allez dans le dossier Ming. Faites "make", puis "make install".

Cela va compiler le fichier libming.so et l'installer dans /usr/lib/, et copier ming.h into /usr/include/. Éditez la ligne PREFIX= dans le fichier Makefile pour indiquer votre dossier d'installation.

Installation

Exemple 1. Compilation CGI avec PHP (Unix)



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

       

Compilez et installez PHP comme d'habitude. Redémarrez votre serveur web si nécessaire.

Maintenant, soit vous ajoutez simplement extension=php_ming.so dans votre fichier php.ini, soit vous ajoutez la ligne dl('php_ming.so'); au début de tous vos scripts qui utilisent Ming.

Configuration à l'exécution

Cette extension ne définit aucune directive de configuration.

Constantes pré-définies

Ces constantes sont définies par cette extension, et ne sont disponibles que si cette extension a été compilée avec PHP, ou bien chargée au moment de l'exécution.

MING_NEW (entier)

MING_ZLIB (entier)

SWFBUTTON_HIT (entier)

SWFBUTTON_DOWN (entier)

SWFBUTTON_OVER (entier)

SWFBUTTON_UP (entier)

SWFBUTTON_MOUSEUPOUTSIDE (entier)

SWFBUTTON_DRAGOVER (entier)

SWFBUTTON_DRAGOUT (entier)

SWFBUTTON_MOUSEUP (entier)

SWFBUTTON_MOUSEDOWN (entier)

SWFBUTTON_MOUSEOUT (entier)

SWFBUTTON_MOUSEOVER (entier)

SWFFILL_RADIAL_GRADIENT (entier)

SWFFILL_LINEAR_GRADIENT (entier)

SWFFILL_TILED_BITMAP (entier)

SWFFILL_CLIPPED_BITMAP (entier)

SWFTEXTFIELD_HASLENGTH (entier)

SWFTEXTFIELD_NOEDIT (entier)

SWFTEXTFIELD_PASSWORD (entier)

SWFTEXTFIELD_MULTILINE (entier)

SWFTEXTFIELD_WORDWRAP (entier)

SWFTEXTFIELD_DRAWBOX (entier)

SWFTEXTFIELD_NOSELECT (entier)

SWFTEXTFIELD_HTML (entier)

SWFTEXTFIELD_ALIGN_LEFT (entier)

SWFTEXTFIELD_ALIGN_RIGHT (entier)

SWFTEXTFIELD_ALIGN_CENTER (entier)

SWFTEXTFIELD_ALIGN_JUSTIFY (entier)

SWFACTION_ONLOAD (entier)

SWFACTION_ENTERFRAME (entier)

SWFACTION_UNLOAD (entier)

SWFACTION_MOUSEMOVE (entier)

SWFACTION_MOUSEDOWN (entier)

SWFACTION_MOUSEUP (entier)

SWFACTION_KEYDOWN (entier)

SWFACTION_KEYUP (entier)

SWFACTION_DATA (entier)

Classes pré-définies

Ces classes sont définies par cette extension, et elles ne seront disponibles que si cette extension a été compilée avec PHP, ou bien chargée dynamiquement.

Table des matières
SWFAction -- SWFAction Class
SWFAction->__construct() -- Creates a new SWFAction
SWFBitmap -- SWFBitmap Class
SWFBitmap->__construct() -- Loads Bitmap object
SWFBitmap->getHeight() -- Returns the bitmap's height
SWFBitmap->getWidth() -- Returns the bitmap's width
SWFButton -- SWFButton Class
SWFButton->__construct() -- Creates a new Button
SWFButton->addAction() -- Adds an action
SWFButton->addASound() -- Associates a sound with a button transition
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->setMenu() -- enable track as menu button behaviour
SWFButton->setOver() -- Alias for addShape(shape, SWFBUTTON_OVER)
SWFButton->setUp() -- Alias for addShape(shape, SWFBUTTON_UP)
SWFDisplayItem -- SWFDisplayItem Class
SWFDisplayItem->addAction() -- Adds this SWFAction to the given SWFSprite instance
SWFDisplayItem->addColor() -- Adds the given color to this item's color transform
SWFDisplayItem->endMask() -- Another way of defining a MASK layer
SWFDisplayItem->getRot() -- 
SWFDisplayItem->getX() -- 
SWFDisplayItem->getXScale() -- 
SWFDisplayItem->getXSkew() -- 
SWFDisplayItem->getY() -- 
SWFDisplayItem->getYScale() -- 
SWFDisplayItem->getYSkew() -- 
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->setMaskLevel() -- Defines a MASK layer at level
SWFDisplayItem->setMatrix() -- Sets the item's transform matrix
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 -- SWFFill Class
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
SWFFont -- SWFFont Class
SWFFont->__construct() -- Loads a font definition
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
SWFFont->getWidth() -- Returns the string's width
SWFFontChar -- SWFFontChar Class
SWFFontChar->addChars() -- Adds characters to a font for exporting font
SWFFontChar->addUTF8Chars() -- Adds characters to a font for exporting font
SWFGradient -- SWFGradient Class
SWFGradient->__construct() -- Creates a gradient object
SWFGradient->addEntry() -- Adds an entry to the gradient list
SWFMorph -- SWFMorph Class
SWFMorph->__construct() -- Creates a new SWFMorph object
SWFMorph->getShape1() -- Gets a handle to the starting shape
SWFMorph->getShape2() -- Gets a handle to the ending shape
SWFMovie -- SWFMovie Class
SWFMovie->__construct() -- Creates a new movie object, representing an SWF version 4 movie
SWFMovie->add() -- Adds any type of data to a movie
SWFMovie->addExport() -- 
SWFMovie->addFont() -- 
SWFMovie->importChar() -- 
SWFMovie->importFont() -- 
SWFMovie->labelFrame() -- Labels a frame
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 the SWF movie in a file
SWFMovie->saveToFile() -- 
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->startSound() -- 
SWFMovie->stopSound() -- 
SWFMovie->streamMP3() -- Streams a MP3 file
SWFMovie->writeExports() -- 
SWFPrebuiltClip -- SWFPrebuiltClip Class
SWFPrebuiltClip->__construct() -- Returns a SWFPrebuiltClip object
SWFShape -- SWFShape Class
SWFShape->__construct() -- Creates a new shape object
SWFShape->addFill() -- Adds a solid fill to the shape
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->drawCurve() -- Draws a curve (relative)
SWFShape->drawCurveTo() -- Draws a curve
SWFShape->drawGlyph() -- Draws the first character in the given string into the shape using the glyph definition from the given font
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
SWFSound -- SWFSound Class
SWFSound -- Returns a new SWFSound object from given file
SWFSoundInstance -- SWFSoundInstance Class
SWFSoundInstance->loopCount() -- 
SWFSoundInstance->loopInPoint() -- 
SWFSoundInstance->loopOutPoint() -- 
SWFSoundInstance->noMultiple() -- 
SWFSprite -- SWFSprite Class
SWFSprite->__construct() -- Creates a movie clip (a sprite)
SWFSprite->add() -- Adds an object to a sprite
SWFSprite->labelFrame() -- Labels frame
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->startSound() -- 
SWFSprite->stopSound() -- 
SWFText -- SWFText Class
SWFText->__construct() -- Creates a new SWFText object
SWFText->addString() -- Draws a string
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
SWFText->getWidth() -- Computes string's width
SWFText->moveTo() -- Moves the pen
SWFText->setColor() -- Sets the current text color
SWFText->setFont() -- Sets the current font
SWFText->setHeight() -- Sets the current font height
SWFText->setSpacing() -- Sets the current font spacing
SWFTextField -- SWFTextField Class
SWFTextField->__construct() -- Creates a text field object
SWFTextField->addChars() -- adds characters to a font that will be available within a textfield
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->setPadding() -- Sets the padding of this textfield
SWFTextField->setRightMargin() -- Sets the right margin width of the text field
SWFVideoStream -- SWFVideoStream Class
SWFVideoStream->__construct() -- Returns a SWFVideoStream object
SWFVideoStream->getNumFrames() -- 
SWFVideoStream->setDimension() -- 
ming_keypress -- Retourne le drapeau d'action pour keyPress(char)
ming_setcubicthreshold --  Fixe le niveau de seuil cubique
ming_setscale --  Définit l'échelle
ming_useconstants -- Use constant pool
ming_useswfversion -- Définit la version SWF