Contents / Previous / Next


Movies with Ming

What is Ming?

Ming is a open-source (LGPL) C library which writes SWF ("Flash") 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 audio, and color transforms. The only thing that's missing is sound events.

Ming is available from: ming.sourceforge.net


Installation

Ming is best installed as module for PHP.
Installation Source: http://ming.sourceforge.net/install.html

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). Or add the path to the ming module in the php.ini file.

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.


Examples

Movie1: <?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(25,25); $s->drawLineTo(25,50); $s->drawLineTo(50,50); $s->drawLineTo(50,25); $s->drawLineTo(25,25); $m = new SWFMovie(); $m->setDimension(320, 240); $m->add($s); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie2:

<?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(25,25); $s->drawLineTo(25,100); $s->drawLineTo(150,100); $s->drawLineTo(25,25); $m = new SWFMovie(); $m->setDimension(320, 240); $m->add($s); $m->setBackground(0, 0, 0xff); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie3:

<?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(-25,-25); $s->drawLineTo(25,-25); $s->drawLineTo(25,25); $s->drawLineTo(-25,25); $s->drawLineTo(-25,-25); $m = new SWFMovie(); $m->setBackground(0, 0xff, 0xff); $m->setDimension(320, 240); $i = $m->add($s); // Instanz erzeugen $i->setDepth(1); $i->moveTo(80, 120); $m->nextFrame(); $i->moveTo(120,120); $m->nextFrame(); $i->moveTo(220,120); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie4:

<?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(-25,-25); $s->drawLineTo(25,-25); $s->drawLineTo(25,25); $s->drawLineTo(-25,25); $s->drawLineTo(-25,-25); $m = new SWFMovie(); $m->setBackground(0, 0xff, 0xff); $m->setDimension(320, 240); $i = $m->add($s); // Instanz erzeugen $i->setDepth(1); $i->moveTo(180, 120); $m->nextFrame(); $i->rotateTo(30); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie5:

<?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(-25,-25); $s->drawLineTo(25,-25); $s->drawLineTo(25,25); $s->drawLineTo(-25,25); $s->drawLineTo(-25,-25); $m = new SWFMovie(); $m->setBackground(0, 0xff, 0xff); $m->setDimension(320, 240); $i = $m->add($s); // Instanz erzeugen $i->setDepth(1); $i->moveTo(180, 120); $m->nextFrame(); $i->scaleTo(2,2); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie6:

<?php $s = new SWFShape(); $f = $s->addFill(0xff, 0, 0); $s->setRightFill($f); $s->movePenTo(-25,-25); $s->drawLineTo(25,-25); $s->drawLineTo(25,25); $s->drawLineTo(-25,25); $s->drawLineTo(-25,-25); $m = new SWFMovie(); $m->setBackground(0, 0xff, 0xff); $m->setDimension(320, 240); $i = $m->add($s); // Instanz erzeugen $i->setDepth(1); $i->moveTo(-80, 120); $m->nextFrame(); $i->moveTo(120,120); $m->nextFrame(); $i->moveTo(130,120); $m->nextFrame(); $i->moveTo(140,120); $m->nextFrame(); $i->moveTo(150,120); $m->nextFrame(); $i->moveTo(160,120); $m->nextFrame(); $i->moveTo(170,120); $m->nextFrame(); $i->moveTo(180,120); $m->nextFrame(); $i->moveTo(190,120); $m->nextFrame(); $i->moveTo(200,120); $m->nextFrame(); $i->moveTo(210,120); $m->nextFrame(); $i->moveTo(220,120); $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>

Movie7:

<?php $m = new SWFMovie(); $m->setDimension(320, 240); $m->setBackground(0x00, 0x00, 0x00); $m->add(new SWFAction(" _quality = 'LOW'; frames._visible = false; sparks = []; ")); $g = new SWFGradient(); $g->addEntry(0, 0xff, 0xff, 0xff, 0xff); $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff); $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f); $g->addEntry(1.0, 0xff, 0xff, 0xff, 0); // gradient shape thing $s = new SWFShape(); $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); $f->scaleTo(0.03); $s->setRightFill($f); $s->movePenTo(-30, -30); $s->drawLine(60, 0); $s->drawLine(0, 60); $s->drawLine(-60, 0); $s->drawLine(0, -60); // need to make this a sprite so we can multColor it $p = new SWFSprite(); $p->add($s); $p->nextFrame(); // put the shape in here, each frame a different color $q = new SWFSprite(); $q->add(new SWFAction("gotoFrame(random(7)+1); stop();")); $i = $q->add($p); $i->multColor(1.0, 1.0, 1.0); $q->nextFrame(); $i->multColor(1.0, 0.5, 0.5); $q->nextFrame(); $i->multColor(1.0, 0.75, 0.5); $q->nextFrame(); $i->multColor(1.0, 1.0, 0.5); $q->nextFrame(); $i->multColor(0.5, 1.0, 0.5); $q->nextFrame(); $i->multColor(0.5, 0.5, 1.0); $q->nextFrame(); $i->multColor(1.0, 0.5, 1.0); $q->nextFrame(); // finally, this one contains the action code $p = new SWFSprite(); $i = $p->add($q); $i->setName('frames'); $p->add(new SWFAction(" dx = _root.dx/3 + random(10)-5; dy = _root.dy/3; x = _root._xmouse; y = _root._ymouse; alpha = 100; ")); $p->nextFrame(); $p->add(new SWFAction(" this._x = x; this._y = y; this._alpha = alpha; x += dx; y += dy; dy += 3; alpha -= 8; ")); $p->nextFrame(); $p->add(new SWFAction("prevFrame(); play();")); $p->nextFrame(); $i = $m->add($p); $i->setName('frames'); $m->nextFrame(); $m->add(new SWFAction(" dx = _xmouse - lastx; dy = _ymouse - lasty; lastx = _xmouse; lasty = _ymouse; if(++num == 11) num = 1; if(sparks[num]) removeMovieClip(sparks[num]); duplicateMovieClip('frames', 'char'+num, num); sparks[num] = this['char'+num]; ")); $m->nextFrame(); $m->add(new SWFAction("prevFrame(); play();")); header('Content-type: application/x-shockwave-flash'); $m->output(); ?>