Index: phpdoc/en/functions/ming.xml +++ phpdoc/en/functions/ming.xml Ming functions for Flash Ming (flash) This documentation ist not finished yet. Don't start to translate it or use it as a programming reference (dams <email protected>). These functions are not yet available if PHP. Introduction 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 &email.ming;. Installation 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 : &url.ming; 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. 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 built into php (unix) 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. 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. swfmovie. swfshape. swfdisplayitem. swfgradient. swfbitmap. swffill. swfmorph. swftext. swffont. swftextfield. swfsprite. swfbutton. SWFMovie Creates a new movie object, representing an SWF version 4 movie. Description new swfmovie void swfmovie creates a new movie object, representing an SWF version 4 movie. SWFMovie has the following methods : swfmovie->output,swfmovie->save, swfmovie->add, swfmovie->remove, swfmovie->nextframe, swfmovie->setbackground, swfmovie->setrate, swfmovie->setdimension, swfmovie->setframes et swfmovie->streammp3. See examples in : swfdisplayitem->rotateto, swfshape->setline, swfshape->addfill... Any example will use this object. SWFMovie->output Dumps your lovingly prepared movie out. Description string swfmovie->output void swfmovie->output dumps your lovingly prepared movie out. In PHP, preceding this with the command <?php header('Content-type: application/x-shockwave-flash'); ?> convinces the browser to display this as a flash movie. See also swfmovie->save See examples in : swfmovie->streammp3, swfdisplayitem->rotateto, swfaction... Any example will use this method. SWFMovie->save Saves your movie in a file. Description string swfmovie->save string filename swfmovie->save saves your movie to the file named filename. See also output SWFMovie->add Adds any type of data to a movie. Description string swfmovie->add ressource instance swfmovie->add adds instance to the current movie. instance is any type of data : Shapes, text, fonts, etc. must all be add'ed to the movie to make this work. For displayable types (shape, text, button, sprite), this returns an SWFDisplayItem, a handle to the object in a display list. Thus, you can add the same shape to a movie multiple times and get separate handles back for each separate instance. See also all other objects (adding this later), and swfmovie->remove See examples in : swfdisplayitem->rotateto and swfshape->addfill. SWFMovie->remove Removes the object instance from the display list. Description string swfmovie->remove ressource instance swfmovie->remove removes the object instance instance from the display list. See also swfmovie->add SWFMovie->setbackground Sets the background color. Description string swfmovie->setbackground int red int green int blue swfmovie->setbackground sets the background color. Why is there no rgba version? Think about it. (Actually, that's not such a dumb question after all- you might want to let the html background show through. There's a way to do that, but it only works on IE4. Search the MM site for details.) SWFMovie->setrate Sets the animation's frame rate. Description string swfmovie->setrate int rate nom_de_la_fonction sets the frame rate to rate, in frame per seconds. Animation will slow down if the player can't render frames fast enough- unless there's a streaming sound, in which case display frames are sacrificed to keep sound from skipping. SWFMovie->setdimension Sets the movie's width and height. Description string swfmovie->setdimension int width int height swfmovie->setdimension sets the movie's width to width and height to height. SWFMovie->setframes Sets the total number of frames in the animation. Description string swfmovie->setframes string numberofframes swfmovie->setframes sets the total number of frames in the animation to numberofframes. SWFMovie->nextframe Moves to the next frame of the animation. Description string swfmovie->nextframe void swfmovie->setframes moves to the next frame of the animation. SWFMovie->streammp3 Streams a MP3 file. Description string swfmovie->streammp3 string mp3FileName swfmovie->streammp3 streams the mp3 file mp3FileName. Not very robust in dealing with oddities (can skip over an initial ID3 tag, but that's about it). Like SWFShape::addJpegFill, this isn't a stable function- we'll probably need to make a separate SWFSound object to contain sound types. Note that the movie isn't smart enough to put enough frames in to contain the entire mp3 stream- you'll have to add (length of song * frames per second) frames to get the entire stream in. Yes, now you can use ming to put that rock and roll devil worship music into your SWF files. Just don't tell the RIAA. <function>swfmovie->streammp3</function> example <?php $m = new SWFMovie(); $m->setRate(12.0); $m->streamMp3("distortobass.mp3"); // use your own MP3 // 11.85 seconds at 12.0 fps = 142 frames $m->setFrames(142); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFDisplayItem Creates a new displayitem object. Description new swfdisplayitem void swfdisplayitem creates a new swfdisplayitem object. Here's where all the animation takes place. After you define a shape, a text object, a sprite, or a button, you add it to the movie, then use the returned handle to move, rotate, scale, or skew the thing. SWFDisplayItem has the following methods : swfdisplayitem->move, swfdisplayitem->moveto, swfdisplayitem->scaleto, swfdisplayitem->scale, swfdisplayitem->rotate, swfdisplayitem->rotateto, swfdisplayitem->skewxto, swfdisplayitem->skewx, swfdisplayitem->skewyto swfdisplayitem->skewyto, swfdisplayitem->setdepth swfdisplayitem->remove, swfdisplayitem->setname swfdisplayitem->setratio, swfdisplayitem->addcolor et swfdisplayitem->multcolor. SWFDisplayItem->moveTo Moves object in global coordinates. Description bool swfdisplayitem->moveto int x int y swfdisplayitem->moveto moves the current object to (x,y) in global coordinates. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->move. SWFDisplayItem->move Moves object in relative coordinates. Description bool swfdisplayitem->move int dx int dy swfdisplayitem->move moves the current object by (dx,dy) from its current position. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->moveto. SWFDisplayItem->scaleTo Scales the object in global coordinates. Description bool swfdisplayitem->scaleto int x int y swfdisplayitem->scaleto scales the current object to (x,y) in global coordinates. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->scale. SWFDisplayItem->scale Scales the object in relative coordinates. Description bool swfdisplayitem->scale int dx int dy swfdisplayitem->scale scales the current object by (dx,dy) from its current position. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->scaleto. SWFDisplayItem->rotateTo Rotates the object in global coordinates. Description bool swfdisplayitem->rotateto double degrees swfdisplayitem->rotateto set the current object rotation to degrees degrees in global coordinates. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. This example bring three rotating string from the background to the foreground. Pretty nice. <function>swfdisplayitem->rotateto</function> example <?php $thetext = "ming!"; $f = new SWFFont("Bauhaus 93.fdb"); $m = new SWFMovie(); $m->setRate(24.0); $m->setDimension(2400, 1600); $m->setBackground(0xff, 0xff, 0xff); // functions with huge numbers of arbitrary // arguments are always a good idea! Really! function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string) { global $f, $m; $t = new SWFText(); $t->setFont($f); $t->setColor($r, $g, $b, $a); $t->setHeight(960); $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); $t->addString($string); // we can add properties just like a normal php var, // as long as the names aren't already used. // e.g., we can't set $i->scale, because that's a function $i = $m->add($t); $i->x = $x; $i->y = $y; $i->rot = $rot; $i->s = $scale; $i->rotateTo($rot); $i->scale($scale, $scale); // but the changes are local to the function, so we have to // return the changed object. kinda weird.. return $i; } function step($i) { $oldrot = $i->rot; $i->rot = 19*$i->rot/20; $i->x = (19*$i->x + 1200)/20; $i->y = (19*$i->y + 800)/20; $i->s = (19*$i->s + 1.0)/20; $i->rotateTo($i->rot); $i->scaleTo($i->s, $i->s); $i->moveTo($i->x, $i->y); return $i; } // see? it sure paid off in legibility: $i1 = text(0xff, 0x33, 0x33, 0xff, 900, 1200, 800, 0.03, $thetext); $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext); $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext); for($i=1; $i<=100; ++$i) { $i1 = step($i1); $i2 = step($i2); $i3 = step($i3); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?> See also swfdisplayitem->rotate. SWFDisplayItem->Rotate Rotates in relative coordinates. Description bool swfdisplayitem->rotate double ddegrees swfdisplayitem->rotate rotates the current object by ddegrees degrees from its current rotation. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->rotateto. SWFDisplayItem->skewXTo Sets the X-skew. Description bool swfdisplayitem->skewxto double degrees swfdisplayitem->skewxto sets the x-skew to degrees. For degrees is 1.0, it means a 45-degree forward slant. More is more forward, less is more backward. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->skewx, swfdisplayitem->skewy and swfdisplayitem->skewyto. SWFDisplayItem->skewX Sets the X-skew. Description bool swfdisplayitem->skewx double ddegrees swfdisplayitem->skewx adds ddegrees to current x-skew. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->skewx, swfdisplayitem->skewy and swfdisplayitem->skewyto. SWFDisplayItem->skewYTo Sets the Y-skew. Description bool swfdisplayitem->skewyto double degrees swfdisplayitem->skewyto sets the y-skew to degrees. For degrees is 1.0, it means a 45-degree forward slant. More is more upward, less is more downward. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->skewy, swfdisplayitem->skewx and swfdisplayitem->skewxto. SWFDisplayItem->skewY Sets the Y-skew. Description bool swfdisplayitem->skewy double ddegrees swfdisplayitem->skewy adds ddegrees to current y-skew. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfdisplayitem->skewyto, swfdisplayitem->skewx and swfdisplayitem->skewxto. SWFDisplayItem->setDepth Sets z-order Description bool swfdisplayitem->setdepth double depth swfdisplayitem->rotate sets the object's z-order to depth. Depth defaults to the order in which instances are created (by add'ing a shape/text to a movie)- newer ones are on top of older ones. If two objects are given the same depth, only the later-defined one can be moved. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. SWFDisplayItem->remove Removes the object from the movie Description bool swfdisplayitem->remove void swfdisplayitem->remove removes this object from the movie's display list. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. See also swfmovie->add. SWFDisplayItem->setName Sets the object's name Description bool swfdisplayitem->setname string name swfdisplayitem->setname sets the object's name to name, for targetting with action script. Only useful on sprites. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. SWFDisplayItem->setRatio Sets the object's ratio to ratio. Description void swfdisplayitem->setratio double ratio swfdisplayitem->setratio sets the object's ratio to ratio. Obviously only useful for morphs. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. This simple example will morph nicely three concentric circles. <function>swfdisplayitem->setname</function> example <?php $p = new SWFMorph(); $g = new SWFGradient(); $g->addEntry(0.0, 0, 0, 0); $g->addEntry(0.16, 0xff, 0xff, 0xff); $g->addEntry(0.32, 0, 0, 0); $g->addEntry(0.48, 0xff, 0xff, 0xff); $g->addEntry(0.64, 0, 0, 0); $g->addEntry(0.80, 0xff, 0xff, 0xff); $g->addEntry(1.00, 0, 0, 0); $s = $p->getShape1(); $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); $f->scaleTo(0.05); $s->setLeftFill($f); $s->movePenTo(-160, -120); $s->drawLine(320, 0); $s->drawLine(0, 240); $s->drawLine(-320, 0); $s->drawLine(0, -240); $g = new SWFGradient(); $g->addEntry(0.0, 0, 0, 0); $g->addEntry(0.16, 0xff, 0, 0); $g->addEntry(0.32, 0, 0, 0); $g->addEntry(0.48, 0, 0xff, 0); $g->addEntry(0.64, 0, 0, 0); $g->addEntry(0.80, 0, 0, 0xff); $g->addEntry(1.00, 0, 0, 0); $s = $p->getShape2(); $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); $f->scaleTo(0.05); $f->skewXTo(1.0); $s->setLeftFill($f); $s->movePenTo(-160, -120); $s->drawLine(320, 0); $s->drawLine(0, 240); $s->drawLine(-320, 0); $s->drawLine(0, -240); $m = new SWFMovie(); $m->setDimension(320, 240); $i = $m->add($p); $i->moveTo(160, 120); for($n=0; $n<=1.001; $n+=0.01) { $i->setRatio($n); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFDisplayItem->addColor Adds the given color to this item's color transform. Description bool swfdisplayitem->addcolor integer red integer green integer blue integer a swfdisplayitem->addcolor adds the color to this item's color transform. The color is given in its RGB form. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. SWFDisplayItem->multColor Multiplies the item's color transform. Description bool swfdisplayitem->multcolor integer red integer green integer blue integer a swfdisplayitem->multcolor multiplies the item's color transform by the given values. The object may be a swfshape, a swfbutton, a swftext or a swfsprite object. It must have been added using the swfmovie->add. This simple example will modify your picture's atmospher to Halloween (use a landscape or bright picture). <function>swfdisplayitem->multcolor</function> example <?php $b = new SWFBitmap("backyard.jpg"); // note use your own picture :-) $s = new SWFShape(); $s->setRightFill($s->addFill($b)); $s->drawLine($b->getWidth(), 0); $s->drawLine(0, $b->getHeight()); $s->drawLine(-$b->getWidth(), 0); $s->drawLine(0, -$b->getHeight()); $m = new SWFMovie(); $m->setDimension($b->getWidth(), $b->getHeight()); $i = $m->add($s); for($n=0; $n<=20; ++$n) { $i->multColor(1.0-$n/10, 1.0, 1.0); $i->addColor(0xff*$n/20, 0, 0); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFShape Creates a new shape object. Description new swfshape void swfshape creates a new shape object. SWFShape has the following methods : swfshape->setline, swfshape->addfill, swfshape->setleftfile, swfshape->setrightfile, swfshape->movepento, swfshape->movepen, swfshape->drawlineto, swfshape->drawline, swfshape->drawcurveto et swfshape->drawcurve. This simple example will draw a big red elliptic quadrant. <function>swfshape</function> example <?php $s = new SWFShape(); $s->setLine(40, 0x7f, 0, 0); $s->setRightFill($s->addFill(0xff, 0, 0)); $s->movePenTo(200, 200); $s->drawLineTo(6200, 200); $s->drawLineTo(6200, 4600); $s->drawCurveTo(200, 4600, 200, 200); $m = new SWFMovie(); $m->setDimension(6400, 4800); $m->setRate(12.0); $m->add($s); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFShape->setLine Sets the shape's line style. Description bool swfshape->setline int width integer red integer green integer blue integer a swfshape->setline sets the shape's line style. width is the line's width. If width is 0, the line's style is removed (then, all other arguments are ignored). If width > 0, then line's color is set to red, green, blue. Last parameter a is optional. swfshape->setline accepts 1, 4 or 5 arguments (not 3 or 2). You must declare all line styles before you use them (see example). This simple example will draw a big "!#%*@", in funny colors and gracious style. <function>swfshape->setline</function> example <?php $s = new SWFShape(); $f1 = $s->addFill(0xff, 0, 0); $f2 = $s->addFill(0xff, 0x7f, 0); $f3 = $s->addFill(0xff, 0xff, 0); $f4 = $s->addFill(0, 0xff, 0); $f5 = $s->addFill(0, 0, 0xff); // bug: have to declare all line styles before you use them $s->setLine(40, 0x7f, 0, 0); $s->setLine(40, 0x7f, 0x3f, 0); $s->setLine(40, 0x7f, 0x7f, 0); $s->setLine(40, 0, 0x7f, 0); $s->setLine(40, 0, 0, 0x7f); $f = new SWFFont('Techno.fdb'); $s->setRightFill($f1); $s->setLine(40, 0x7f, 0, 0); $s->drawGlyph($f, '!'); $s->movePen($f->getWidth('!'), 0); $s->setRightFill($f2); $s->setLine(40, 0x7f, 0x3f, 0); $s->drawGlyph($f, '#'); $s->movePen($f->getWidth('#'), 0); $s->setRightFill($f3); $s->setLine(40, 0x7f, 0x7f, 0); $s->drawGlyph($f, '%'); $s->movePen($f->getWidth('%'), 0); $s->setRightFill($f4); $s->setLine(40, 0, 0x7f, 0); $s->drawGlyph($f, '*'); $s->movePen($f->getWidth('*'), 0); $s->setRightFill($f5); $s->setLine(40, 0, 0, 0x7f); $s->drawGlyph($f, '@'); $m = new SWFMovie(); $m->setDimension(3000,2000); $m->setRate(12.0); $i = $m->add($s); $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFShape->addFill Adds a solid fill to the shape. Description string swfshape->addfill integer red integer green integer blue integer a string swfshape->addfill SWFbitmap bitmap integer flags string swfshape->addfill SWFGradient gradient integer flags swfshape->addfill adds a solid fill to the shape's list of fill styles. swfshape->addfill accepts three different types of arguments. red, green, blue is a color (RGB mode). Last parameter a is optional. The bitmap argument is an swfbitmap object. The flags argument can be one of the following values : SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP. Default is SWFFILL_TILED_BITMAP. I think. The gradient argument is an swfgradient object. The flags argument can be one of the following values : SWFFILL_RADIAL_GRADIENT or SWFFILL_LINEAR_GRADIENT. Default is SWFFILL_LINEAR_GRADIENT. I'm sure about this one. Really. swfshape->addfill returns an swffill object for use with the swfshape->setfill functions described below. See also swfshape->setfill. This simple example will draw a frame on a bitmap. Ah, here's another buglet in the flash player- it doesn't seem to care about the second shape's bitmap's transformation in a morph. According to spec, the bitmap should stretch along with the shape in this example.. <function>swfshape->addfill</function> example <?php $p = new SWFMorph(); $b = new SWFBitmap("alphafill.jpg"); // use your own bitmap $width = $b->getWidth(); $height = $b->getHeight(); $s = $p->getShape1(); $f = $s->addFill($b, SWFFILL_TILED_BITMAP); $f->moveTo(-$width/2, -$height/4); $f->scaleTo(1.0, 0.5); $s->setLeftFill($f); $s->movePenTo(-$width/2, -$height/4); $s->drawLine($width, 0); $s->drawLine(0, $height/2); $s->drawLine(-$width, 0); $s->drawLine(0, -$height/2); $s = $p->getShape2(); $f = $s->addFill($b, SWFFILL_TILED_BITMAP); // these two have no effect! $f->moveTo(-$width/4, -$height/2); $f->scaleTo(0.5, 1.0); $s->setLeftFill($f); $s->movePenTo(-$width/4, -$height/2); $s->drawLine($width/2, 0); $s->drawLine(0, $height); $s->drawLine(-$width/2, 0); $s->drawLine(0, -$height); $m = new SWFMovie(); $m->setDimension($width, $height); $i = $m->add($p); $i->moveTo($width/2, $height/2); for($n=0; $n<1.001; $n+=0.03) { $i->setRatio($n); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFShape->setLeftFill Sets left rasterizing color. Description string swfshape->setleftfill swfgradient fill string swfshape->setleftfill integer red integer green integer blue integer a What this nonsense is about is, every edge segment borders at most two fills. When rasterizing the object, it's pretty handy to know what those fills are ahead of time, so the swf format requires these to be specified. swfshape->setleftfill sets the fill on the left side of the edge- that is, on the interior if you're defining the outline of the shape in a counter-clockwise fashion. The fill object is an SWFFill object returned from one of the addFill functions above. This seems to be reversed when you're defining a shape in a morph, though. If your browser crashes, just try setting the fill on the other side. Shortcut for swfshape->setleftfill($s->addfill($r, $g, $b [, $a]));. See also swfshape->setrightfill. SWFShape->setRightFill Sets right rasterizing color. Description string swfshape->setrightfill swfgradient fill string swfshape->setrightfill integer red integer green integer blue integer a See also swfshape->setleftfill. Shortcut for swfshape->setrightfill($s->addfill($r, $g, $b [, $a]));. SWFShape->movePenTo Moves the shape's pen. Description string swfshape->movepento integer x integer y swfshape->setrightfill move the shape's pen to (x,y) in the shape's coordinate space. See also swfshape->movepen, swfshape->drawcurveto, swfshape->drawlineto et swfshape->drawline. SWFShape->movePen Moves the shape's pen (relative). Description string swfshape->movepen integer dx integer dy swfshape->setrightfill move the shape's pen from coordinates (current x,current y) to (current x + dx, current y + dy) in the shape's coordinate space. See also swfshape->movepento, swfshape->drawcurveto, swfshape->drawlineto et swfshape->drawline. SWFShape->drawLineTo Draws a line. Description string swfshape->drawlineto integer x integer y swfshape->setrightfill draws a line (using the current line style, set by swfshape->setline) from the current pen position to point (x,y) in the shape's coordinate space. See also swfshape->movepento, swfshape->drawcurveto, swfshape->movepen et swfshape->drawline. SWFShape->drawLine Draws a line (relative). Description string swfshape->drawline integer dx integer dy swfshape->setrightfill draws a line (using the current line style set by swfshape->setline) from the current pen position to displacement (dx,dy). See also swfshape->movepento, swfshape->drawcurveto, swfshape->movepen et swfshape->drawlineto. SWFShape->drawCurveTo Draws a curve. Description string swfshape->drawcurveto integer controlx integer controly integer anchorx integer anchory swfshape->drawcurveto draws a quadratic curve (using the current line style, set by swfshape->setline) from the current pen position to (anchorx,anchory) using (controlx,controly) as a control point. That is, head towards the control point, then smoothly turn to the anchor point. See also swfshape->drawlineto, swfshape->drawline, swfshape->movepento et swfshape->movepen. SWFShape->drawCurve Draws a curve (relative). Description string swfshape->drawcurve integer controldx integer controldy integer anchordx integer anchordy swfshape->drawcurve draws a quadratic curve (using the current line style,set by swfshape->setline) from the current pen position to the relative position (anchorx,anchory) using relative control point (controlx,controly). That is, head towards the control point, then smoothly turn to the anchor point. See also swfshape->drawlineto, swfshape->drawline, swfshape->movepento et swfshape->movepen. SWFGradient Loads a font definition Description new swfgradient void swfgradient creates a new SWFGradient object. After you've added the entries to your gradient, you can use the gradient in a shape fill with the swfshape->addfill method. SWFGradient has the following methods : swfgradient->addentry. This simple example will draw a big black-to-white gradient as background, and a redish disc in its center. <function>swfgradient</function> example <?php $m = new SWFMovie(); $m->setDimension(320, 240); $s = new SWFShape(); // first gradient- black to white $g = new SWFGradient(); $g->addEntry(0.0, 0, 0, 0); $g->addEntry(1.0, 0xff, 0xff, 0xff); $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); $f->scaleTo(0.01); $f->moveTo(160, 120); $s->setRightFill($f); $s->drawLine(320, 0); $s->drawLine(0, 240); $s->drawLine(-320, 0); $s->drawLine(0, -240); $m->add($s); $s = new SWFShape(); // second gradient- radial gradient from red to transparent $g = new SWFGradient(); $g->addEntry(0.0, 0xff, 0, 0, 0xff); $g->addEntry(1.0, 0xff, 0, 0, 0); $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); $f->scaleTo(0.005); $f->moveTo(160, 120); $s->setRightFill($f); $s->drawLine(320, 0); $s->drawLine(0, 240); $s->drawLine(-320, 0); $s->drawLine(0, -240); $m->add($s); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFGradient->addEntry Adds an entry to the gradient list. Description string swfgradient->addentry double ratio integer red integer green integer blue integer a swfgradient->addentry adds an entry to the gradient list. ratio is a number between 0 and 1 indicating where in the gradient this color appears. Thou shalt add entries in order of increasing ratio. red, green, blue is a color (RGB mode). Last parameter a is optional. SWFBitmap Loads Bitmap object Description new swfbitmap string filename integer alphafilename swfbitmap creates a new SWFBitmap object from the Jpeg or DBL file named filename. alphafilename indicates a MSK file to be used as an alpha mask for a Jpeg image. We can only deal with baseline (frame 0) jpegs, no baseline optimized or progressive scan jpegs! SWFBitmap has the following methods : swfbitmap->getwidth and swfbitmap->getheight. You can't import png images directly, though- have to use the png2dbl utility to make a dbl ("define bits lossless") file from the png. The reason for this is that I don't want a dependency on the png library in ming- autoconf should solve this, but that's not set up yet. Import PNG files <?php $s = new SWFShape(); $f = $s->addFill(new SWFBitmap("png.dbl")); $s->setRightFill($f); $s->drawLine(32, 0); $s->drawLine(0, 32); $s->drawLine(-32, 0); $s->drawLine(0, -32); $m = new SWFMovie(); $m->setDimension(32, 32); $m->add($s); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> And you can put an alpha mask on a jpeg fill. <function>swfbitmap</function> example <?php $s = new SWFShape(); // .msk file generated with "gif2mask" utility $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); $s->setRightFill($f); $s->drawLine(640, 0); $s->drawLine(0, 480); $s->drawLine(-640, 0); $s->drawLine(0, -480); $c = new SWFShape(); $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); $c->drawLine(40, 0); $c->drawLine(0, 40); $c->drawLine(-40, 0); $c->drawLine(0, -40); $m = new SWFMovie(); $m->setDimension(640, 480); $m->setBackground(0xcc, 0xcc, 0xcc); // draw checkerboard background for($y=0; $y<480; $y+=40) { for($x=0; $x<640; $x+=80) { $i = $m->add($c); $i->moveTo($x, $y); } $y+=40; for($x=40; $x<640; $x+=80) { $i = $m->add($c); $i->moveTo($x, $y); } } $m->add($s); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFBitmap->getWidth Returns the bitmap's width. Description int swfbitmap->getwidth void swfbitmap->getwidth returns the bitmap's width in pixels. See also swfbitmap->getheight. SWFBitmap->getHeight Returns the bitmap's height. Description int swfbitmap->getheight void swfbitmap->getheight returns the bitmap's height in pixels. See also swfbitmap->getwidth. SWFFill Loads SWFFill object Description The swffill object allows you to transform (scale, skew, rotate) bitmap and gradient fills. swffill objects are created by the swfshape->addfill methods. SWFFill has the following methods : swffill->moveto and swffill->scaleto, swffill->rotateto, swffill->skewxto and swffill->skewyto. SWFFill->moveTo Moves fill origin Description int swffill->moveto integer x integer y swffill->moveto moves fill's origin to (x,y) in global coordinates. SWFFill->scaleTo Sets fill's scale Description int swffill->scaleto integer x integer y swffill->scaleto sets fill's scale to x in the x-direction, y in the y-direction. SWFFill->rotateTo Sets fill's rotation Description int swffill->rotateto double degrees swffill->rotateto sets fill's rotation to degrees degrees. SWFFill->skewXTo Sets fill x-skew Description int swffill->skewxto double x swffill->skewxto sets fill x-skew to x. For x is 1.0, it is a is a 45-degree forward slant. More is more forward, less is more backward. SWFFill->skewYTo Sets fill y-skew Description int swffill->skewyto double y swffill->skewyto sets fill y-skew to y. For y is 1.0, it is a is a 45-degree upward slant. More is more upward, less is more downward. SWFMorph Creates a new SWFMorph object. Description new swfmorph void swfmorph creates a new SWFMorph object. Also called a "shape tween". This thing lets you make those tacky twisting things that make your computer choke. Oh, joy! The methods here are sort of weird. It would make more sense to just have newSWFMorph(shape1, shape2);, but as things are now, shape2 needs to know that it's the second part of a morph. (This, because it starts writing its output as soon as it gets drawing commands- if it kept its own description of its shapes and wrote on completion this and some other things would be much easier.) SWFMorph has the following methods : swfmorph->getshape1 and swfmorph->getshape1. This simple example will morph a big red square into a smaller blue black-bordered square. <function>swfmorph</function> example <?php $p = new SWFMorph(); $s = $p->getShape1(); $s->setLine(0,0,0,0); /* Note that this is backwards from normal shapes (left instead of right). I have no idea why, but this seems to work.. */ $s->setLeftFill($s->addFill(0xff, 0, 0)); $s->movePenTo(-1000,-1000); $s->drawLine(2000,0); $s->drawLine(0,2000); $s->drawLine(-2000,0); $s->drawLine(0,-2000); $s = $p->getShape2(); $s->setLine(60,0,0,0); $s->setLeftFill($s->addFill(0, 0, 0xff)); $s->movePenTo(0,-1000); $s->drawLine(1000,1000); $s->drawLine(-1000,1000); $s->drawLine(-1000,-1000); $s->drawLine(1000,-1000); $m = new SWFMovie(); $m->setDimension(3000,2000); $m->setBackground(0xff, 0xff, 0xff); $i = $m->add($p); $i->moveTo(1500,1000); for($r=0.0; $r<=1.0; $r+=0.1) { $i->setRatio($r); $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFMorph->getshape1 Gets a handle to the starting shape Description int swfmorph->getshape1 void swfmorph->getshape1 gets a handle to the morph's starting shape. swfmorph->getshape1 returns an swfshape object. SWFMorph->getshape2 Gets a handle to the ending shape Description int swfmorph->getshape2 void swfmorph->getshape2 gets a handle to the morph's ending shape. swfmorph->getshape2 returns an swfshape object. SWFMorph Creates a new SWFText object. Description new swftext void swftext creates a new SWFText object, fresh for manipulating. SWFText has the following methods : swftext->setfont, swftext->setheight, swftext->setspacing, swftext->setcolor, swftext->moveto, swftext->addstring and swftext->getwidth. This simple example will draw a big yellow "PHP generates Flash with Ming" text, on white background. <function>swftext</function> example <?php $f = new SWFFont("Techno.fdb"); $t = new SWFText(); $t->setFont($f); $t->moveTo(200, 2400); $t->setColor(0xff, 0xff, 0); $t->setHeight(1200); $t->addString("PHP generates Flash with Ming!!"); $m = new SWFMovie(); $m->setDimension(5400, 3600); $m->add($t); header('Content-type: application/x-shockwave-flash'); $m->output(); ?> SWFText->setFont Sets the current font Description int swftext->setfont string font swftext->setfont sets the current font to font. SWFText->setHeight Sets the current font heigh Description int swftext->setheight integer height swftext->setheight sets the current font height to height. Default is 240. SWFText->setSpacing Sets the current font spacing Description int swftext->setspacing double spacing swftext->setspacing sets the current font spacing to spacingspacing. Default is 1.0. 0 is all of the letters written at the same point. This doesn't really work that well because it inflates the advance across the letter, doesn't add the same amount of spacing between the letters. I should try and explain that better, prolly. Or just fix the damn thing to do constant spacing. This was really just a way to figure out how letter advances work, anyway.. So nyah. SWFText->setColor Sets the current font heigh Description int swftext->setcolor integer red integer green integer blue integer a swftext->setspacing changes the current text color. Default is black. I think. Color is represented using the RGB system. SWFText->moveTo Moves the pen Description int swftext->moveto integer x integer y swftext->moveto moves the pen (or cursor, if that makes more sense) to (x,y) in text object's coordinate space. If either is zero, though, value in that dimension stays the same. Annoying, should be fixed. SWFText->addString Draws a string Description int swftext->addstring string string swftext->addstring draws the string string at the current pen (cursor) location. Pen is at the baseline of the text; i.e., ascending text is in the -y direction. SWFText->getWidth Computes string's width Description int swftext->addstring string string swftext->addstring returns the rendered width of the string string at the text object's current font, scale, and spacing settings. SWFFont Loads a font definition Description new swffont string filename If name is the name of an FDB file (i.e., it ends in ".fdb"), load the font definition found in said file. Otherwise, create a browser-defined font reference. FDB ("font definition block") is a very simple wrapper for the SWF DefineFont2 block which contains a full description of a font. One may create FDB files from SWT Generator template files with the included makefdb utility- look in the util directory off the main ming distribution directory. Browser-defined fonts don't contain any information about the font other than its name. It is assumed that the font definition will be provided by the movie player. The fonts _serif, _sans, and _typewriter should always be available. For example: <?php $f = newSWFFont("_sans"); ?> will give you the standard sans-serif font, probably the same as what you'd get with <font name="sans-serif"> in HTML. Returns a reference to the font definition, for use in the SWFText setFont method and the SWFTextField setFont method. SWFFont has the following methods : swffont->getwidth. getwidth Returns the string's width Description string swffont->getwidth string string nom_de_la_fonction returns the string string's width, using font's default scaling. You'll probably want to use the SWFText version of this method which uses the text object's scale. SWFTextField Creates a text field object Description new swftextfield int flags swftextfield creates a new text field object. Text Fields are less flexible than swftext objects- they can't be rotated, scaled non-proportionally, or skewed, but they can be used as form entries, and they can use browser-defined fonts. The optional flags change the text field's behavior. It has the following possibles values : SWFTEXTFIELD_NOEDIT : indicates that the field shouldn't be user-editable SWFTEXTFIELD_PASSWORD obscures the data entry SWFTEXTFIELD_DRAWBOX draws the outline of the textfield SWFTEXTFIELD_MULTILINE allows multiple lines SWFTEXTFIELD_WORDWRAP allows text to wrap SWFTEXTFIELD_NOSELECT makes the field non-selectable Flags are combined with the bitwise OR operation. For example, <?php $t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT); ?> creates a totally useless non-editable password field. SWFTextField has the following methods : swftextfield->setfont, swftextfield->setbounds, swftextfield->align, swftextfield->setheight, swftextfield->setleftmargin, swftextfield->setrightmargin, swftextfield->setmargins, swftextfield->setindentation, swftextfield->setlinespacing, swftextfield->setcolor, swftextfield->setname et swftextfield->addstring. SWFTextField->setFont Sets the text field font Description int swftextfield->setfont string font swftextfield->setfont sets the text field font to the [browser-defined?] font font. SWFTextField->setbounds Sets the text field width and height Description int swftextfield->setbounds int width int height swftextfield->setbounds sets the text field width to width and height to height. If you don't set the bounds yourself, Ming makes a poor guess at what the bounds are. SWFTextField->align Sets the text field width and height Description int swftextfield->align int alignement swftextfield->align sets the text field alignment to alignement. Valid values for alignement are: SWFTEXTFIELD_ALIGN_LEFT, SWFTEXTFIELD_ALIGN_RIGHT, SWFTEXTFIELD_ALIGN_CENTER and SWFTEXTFIELD_ALIGN_JUSTIFY. SWFTextField->setHeight Sets the font height of this text field font. Description int swftextfield->setheight int height swftextfield->setheight sets the font height of this text field font to the given height height. Default is 240. SWFTextField->setLeftMargin Sets the left margin width of the text field. Description int swftextfield->setleftmargin int width swftextfield->setleftmargin sets the left margin width of the text field to width. Default is 0. SWFTextField->setrightMargin Sets the right margin width of the text field. Description int swftextfield->setrightmargin int width swftextfield->setrightmargin sets the right margin width of the text field to width. Default is 0. SWFTextField->setMargins Sets the margins width of the text field. Description int swftextfield->setmargins int left int right swftextfield->setmargins set both margins at once, for the man on the go. SWFTextField->setindentation Sets the indentation of the first line. Description int swftextfield->setindentation int width swftextfield->setindentation sets the indentation of the first line in the text field, to width. SWFTextField->setLineSpacing Sets the line spacing of the text field. Description int swftextfield->setlinespacing int height swftextfield->setlinespacing sets the line spacing of the text field to the height of height. Default is 40. SWFTextField->setcolor Sets the color of the text field. Description int swftextfield->setcolor integer red integer green integer blue integer a swftextfield->setcolor sets the color of the text field. Default is fully opaque black. Color is represented using RGB system. SWFTextField->setname Sets the variable name Description int swftextfield->setname string name swftextfield->setname sets the variable name of this text field to name, for form posting and action scripting purposes. SWFTextField->addstring Concatenates the given string to the text field Description int swftextfield->addstring string string swftextfield->setname concatenates the string string to the text field. SWFSprite Creates a movie clip (a sprite) Description new swfsprite void SWFSprite are also known as a "movie clip", this allows one to create objects which are animated in their own timelines. Hence, the sprite has most of the same methods as the movie. SWFSprite has the following methods : swfsprite->add, swfsprite->remove, swfsprite->nextframe swfsprite->setframes. This simple example will spin gracefully a big