Ming - an SWF output library and PHP module


2.13.01 - Ming CVS Access

The guys over at sourceforge have anonymous CVS working, so now you can impress your friends with the latest cutting-edge source code. Well, actually, it's not really moving much at all, but if you spot a bug and I fix it I'll post the patch into CVS long before posting a new release.

cvs -d:pserver:anonymous@cvs.ming.sourceforge.net:/cvsroot/ming login
(just hit return when it asks for a password)

cvs -z8 -d:pserver:anonymous@cvs.ming.sourceforge.net:/cvsroot/ming co ming

If you want write access to the ming CVS tree, email me with your sourceforge username. No telling when you'll actually be able to access it, though..

And hey, speaking of bugs- why not try the sourceforge bug tracking system for reporting bugs instead of emailing me? That way I won't just let it get lost in my inbox and never get around to it..


1.25.01 - 0.0.9c

This version adds the drawCubic function for drawing cubic bezier curves, and a number of assorted bug fixes. And probably plenty more bugs.

$s->drawCurve(bx, by, cx, cy, dx, dy);
$s->drawCubic(bx, by, cx, cy, dx, dy);
both do the same thing: draw a cubic bezier from the current pen position, using the three given points as control points. To control how "tight" the approximation is, use the
Ming_setCubicThreshold(num);
function. This gives the amount of error in approximation that each subdivision of the curve needs in order to stop recursing. The default is 20000- if your curves are too sloppy, lower the number.

(Oh, and the approximation code is a little buggy, but it seems to work properly in all practical cases.)

Note that this version installs as a shared library- you should no longer have to tell php where it lives, but you'll have to do "make install" after you build the ming library. And "make static" does the traditional libming.a build.

The examples have been split off to another package.

Ooh, and here's a fun new example. Don't forget to roll your mouse over it!


1.17.01 - About that PHP API version problem-

Try this build of the php_ming.so: php4_0_3-ming_so.tgz if you were getting complaints from php about the API versions needing to match.


1.4.01 - 0.0.9b: more bugs fixed

Namely: instances don't pop back to (0,0) when you rotate or skew them, removing display items doesn't cause trouble in the python module, and.. some other stuff I can't remember. Oh, I finally ported all of the examples to plain c code. That was a real treat, believe me.

So grab it, try it out, let me know if it causes you any existential malaise.


1.3.01 - Documentation updated

No promises that it's all correct, but it's at least somewhat current now. Plus, it now includes the Python, C++, and C functions.

Here's the goods.


12.15.00 - 0.0.9: all you're getting from me for xmas

I was aiming for 0.1.0 this time but there's a fair bit of new code in here, most of it written at four in the morning, so I'm not willing to put the "stable" mark on ming quite yet. What's new:

c++ wrapper: actually just a huge header file which cleverly replaces the c structs with objects and provides the functions as object methods.

Optimized outputBlock generation: that's the thing that makes animation work. Ming used to put stuff in there it didn't need to. And even the wrong stuff in some circumstances. Now it doesn't. I hope.

Improved fill and line handling in shapes: used to be you'd have to declare all of your fills and linestyles before you started drawing. Not any more.

swftophp utility updated: now actually works! It doesn't do quite everything I want it to, but at least it's usable.

another fill shortcut: with php you can just do

$s->setLeftFill(r,g,b[,a]);
now instead of
$s->setLeftFill($s->addFill(r,g,b[,a]));
If this seems like a useful thing, I'll try and emulate it in the Python and c++ wrappers.

Here's the source package. Requires: PHP 4.0.2 or higher for PHP, Python 1.5.2 or higher for Python, and I have no idea for Ruby.

Also, here's a tutorial I've started. If you have suggestions for topics/improvements/whatnot (other than "stop being such a smartass") please do share.


11.20.00 - spank me

If you're having trouble with the Python wrapper code, here's replacements for ming-0.0.4/ming.i and ming-0.0.4/py_ext/ming.py that actually work. Those packaged with 0.0.4 don't feel like displaying text at all. Which is bad.


11.19.00 - 0.0.4: one step closer..

I accidentally fixed the memory leaks. I ran into an annoying freed memory read problem, so I loaded ming/php into purify, probably the most useful program ever written, to figure out what was going on. And then I just decided to fix all the leaks, too. So Ming is now a lot safer to use in a production environment. So I'll try and be better about leaving backwards compatibility in the script-level apis now.

Another swell thing that's happened recently is Steve Spicklemire has wedged Ming into Zope in a module called Zwiff. In a possibly misguided attempt to help the Zopesters out there, I fixed the ming.py interface to match the PHP api, so the PHP documentation should be valid and useful now. And, again, I tried to leave the old classes and functions working, but I might have missed something. If your old code doesn't work, let me know and I'll see what I can do.

Oh, and all of the PHP examples are available for Python now, check the "examples" directory.

SWFShape::drawGlyph

..is today's new function. It draws a glyph outline into an SWFShape. This lets you do fun things like change the linestyle and fill properties, which you can't do with SWFText objects. Here's a PHP example.


10.24.00 - 0.0.3a: a new hope

I finally added a bunch of small things that I'd been putting off: gradients, color transforms, access to fill transforms, and probably a few other things I forget right now. One consequence of this is that a few functions have changed, so most existing code will need to be tweaked to work with this rev of ming. (Which is why this is new html here, I had to clean a lot of the example code..) Here's a summary:

  • SWFShape::setBitmapFill, SWFShape::setSolidFill replaced with SWFShape::setFill
    Okay, before I go any further- I'm talking in terms of the php interface here. Since it's mostly just a shallow wrapper for the c library, you should be able to figure out what these changes mean in terms of the underlying code (And good news there, too- the c header files are a lot cleaner now..) or another language wrapper if you're already familiar with it.

    So now there are separate SWFBitmap and SWFGradient objects; you just pass these to setFill and it figures out how it needs to deal with it.

  • SWFShape::setFillStyle0 and SWFShape::setFillStyle1 replaced with SWFShape::setLeftFill and SWFShape::setRightFill, respectively
    This should make it easier to figure out which one to use- setLeftFill means you're changing the fill that's on the left of the lines you're drawing in the shape- that is, it's on the interior if you're drawing the shape outline in a counter-clockwise fashion.

    The only problem is, this seems to be opposite for morphs. When I've set the fill in the way described above in SWFMorphs, it crashes the player. If your movie crashes, try swapping setRightFill for setLeftFill and vice versa..

  • SWFShape::addLineStyle and SWFShape::setLineStyle replaced with SWFShape::setLine
    Instead of making you keep track of line styles, this new function checks the shape's line style table for the style you request and only creates a new style if necessary.
    Now, a quick blurb about new features:

  • Color transforms
    These allow you to tweak the color of drawable objects. You can set a color to be added to the object, and a scaling factor for each of the rgb[a] components of the object.

    <small rant>Unfortunately, it doesn't let you define a matrix by which to multiply the color vector. That would totally rock, you could do hue shifting and grayscaling and other weird stuff.. But here you can only give another vector that gets dotted with the object color.</small rant>

  • Gradients
    About damn time! In striped and donut varieties. Or "linear" and "radial" if you wanna be all techy.
  • Transformable Fills
    This means you can set the center, scaling, rotation and skew for gradient and bitmap fills. This is a good thing, long overdue.


    10/13/00
    0.0.2e

    Added rudimentary support for PNG bitmaps. Fixes by Tim Goetze add proper kerning table lookups and much less segfaulting to text operations.

    See the examples for usage, etc. Download here.


    10/04/00
    Windows users! Achtung!

    Highly suggested you truck on over to www.php4win.de for all your binary needs. Reportedly has a dll build of ming that works on php-4.0.2 and 4.0.3-dev. Many thanks to those bold enough to deal with my mucky code.


    9/15/00 1.30am
    oops

    Was leaking a filehandle in the action compiler. Fixed now.


    9/14/00
    0.0.2d - alpha masks for jpeg bitmaps

    Check the examples. Download source or .so module.


    9/6/00
    in case you hadn't guessed..

    I've been busy.

    But the great thing about free software is that other people do stuff and you can take credit for it. Take Christian Becker, for example- he goes through all the trouble of building a dll version of php/ming, sends it to me, and now I get to put it here and let it make me look good. Doesn't seem fair..

    So anyway, here's the skinny: just take it, put it in your php extension directory (or just \windows\system) and add "extension=php_ming.dll" to your php.ini file. Or force-load it in your scripts with dl('php_ming.dll').

    Two notes: this .dll only works with php-4.0.1pl2 (and maybe previous versions, but not 4.0.2), and font loading doesn't seem to work.

    Also, in a vain and selfish attempt to steal some of Christian's glory, I've made a php_ming.so library so the unix people who install binaries instead of building from source can use ming as well. Same installation as above, more or less, though I build this one on 4.0.2, so older versions might not work. To find your php extension directory, run php-config --extension-dir.


    7/23/00
    new release 0.0.2c
    Many fixes (and probably lots of breaks, too) to the compiler, an swf->php utility added. It's not perfect, but it might help you see how php/ming works, 'specially the action script stuff.

    download 0.0.2c


    7/20/00
    Uh, just figured out why I wasn't getting any more subscriptions to the announce & user lists. Here's the linkage again:

    ming-announce - announcements only, average one message a week.

    ming-fun - fun with Ming! Tell us what you're doing with Ming! Ask questions about Ming! TALK ABOUT MING, damnit! average zero messages a week.


    7/11/00
    Together, at last- Ming and Python!

    Okay, I'll admit it, I know absolutely nothing about python. But that won't stop me from heaping enormous praise upon these fine folks who made a set of python wrappers for ming:

    http://www.elecomsolutions.com/noze/software/pming/

    Anything that makes these infernal micro-computing machines more useful to us, the superior humans, is a very good thing.


    7/10/00
    New stuff! Less bugs! More bugs!

    Avoiding the obvious Shakespearean quandary over what version number to give this, here's what's new:

  • SWFTextField is.. a text field!

  • Browser-defined fonts. Super handy for text fields (see above).

  • Very cool action decompiler in the listswf util turns action bytecode into that c-like action script stuff I love so much (when it works).

  • Type 2 buttons rendered. This means you can do fancier action stuff. Check the examples for.. an example.

  • Some really stupid compiler stuff fixed, like simple increments actually work now. And setTarget, too.

    download version 0.0.2b

    PHP documentation
    Examples

    Getting an error when you compile? Something about yyparse call not matching function prototype? See below.


    7/1/00
    Actions! Buttons! Sprites! Morphs! New in version 0.0.2a!

    Actions are made from c-like script code with a swank little compiler- much, much faster than clicking through half a dozen menus and dialogs for every command you want. And there's plenty of exciting bugs to discover!

    Buttons are.. you know what buttons are: roll over 'em, click 'em. Now that's entertainment!

    Sprites (aka movie clips) are little movies inside your movie! Whoa!

    Morphs are those fancy twisting squiggles that are used in all the wrong places and make your computer crawl!

    download version 0.0.2a

    (note: ming-0.0.2a requires php-4.0.1. If you really want to compile with 4.0.0, look in the ming.c file in the php_ext directory- see down there at the bottom, that bit of code that's commented out? Uncomment it, and comment the bit below it. Very good.)


    Ming README:

    
    MING THE MODULE
    
    It's an SWF output library.  And it's a PHP module.
    
    It lets you create: shapes (including morphs), text, sprites (aka movie
    clips), buttons, and actions in flash movies.  There's also a bit of mp3
    streaming just for fun..
    
    The library code comes in two parts: a set of functions only concerned
    with writing a valid swf file, and a separate body of code to abstract out
    the details of the SWF format.  The idea is that one shouldn't need to
    know anything about the SWF specification to make it work.
    
    The PHP module wraps Ming objects in PHP objects.  Pretty cool..
    
    Ming is released under the LGPL.  See file LICENSE for the gory details.
    
    -dave@opaque.net
    
    
    BUILDING and INSTALLING:
    
    no fancy autoconf nonsense here, just raw old-fashioned Makefiles.
    
      unpack the tarfile (which you've obviously already done)
      make
    
      mkdir <phpdir>/ext/ming
      cp php_ext/* <phpdir>/ext/ming
      cd <phpdir>
      ./buildconf
      ./configure --with-ming=<mingdir> <other config options>
      build and install php as usual,
      restart web server if necessary
    
    
    USING MING:
    
      Copy the examples from the examples directory to your web doc space.
      Look at them with your web browser.
      Make your own, better, examples and send them to me.
    
    
    Ming appears to work fine on RH6.1 with PHP-4.0.0.  YMMV, caveat emptor,
    carpe diem, et cetera.
    
    Macromedia(r) and Flash(tm) are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries.

    Macromedia(r) does not sponsor, affiliate, or endorse this product and/or services. Nor does China.

    All content Copyright (C) 2000-2001 Opaque Industries except where noted otherwise.