See also,
php stuff (if you're desperate), or
Flash stuff, which also covers other methods of SWF generation. AFAICT there are
at least 3 free-software tools other than Ming.
Ming is quite old and still active, but the docs seem to be (1) very patchy and incomplete, and (2) out of date in many parts. Much of the documentation is pretty useless, except as vague pointers towards things to investigate for yourself by trial-and-error. Which I have done. (that doesn't unfortunately mean I've written up all my findings yet, sorry)
Some of which has been experiments based on the example code on the php docs, which is really miserably broken. I derived some working scripts from those though, with which I managed to figure some details out. I ought to check the "basic sprite examples" there too, see if I can fix those and learn stuff from them.
I also read a lot of the example code at GazbMing site, although a fair bit of that was quite old too. Not as badly though, and at least it had been tested- the first of the PHPdocs examples purported to be a spinning square, and on checking, was a lurching triangle because a corner had been left out. Lovely. The GazbMing ones have a compiled version of each script shown (except in some cases they differ from the source, and in one case the source is absent), but this means you can't view the source without having the movie shown and potentially crashing the browser when you leave the page. (Unless you're one of those lucky folks whose flash plugin is perfectly reliable)
Classes
(Warning: Several of the subpages linked here aren't yet filled in, had other things to do; however the overview given on this page should get you somewhere anyway)
Ming has several classes, which AFAICT all/mostly mirror those available in SWF. The most important ones are:
- SWFMovie SWFMovie, don't get these confused with movie clips! A "Movie" is the entire Flash animation file. Stupid name really. You fill a "Movie" with sprites and other such objects.
- SWFSprite SWFSprite, aka a MovieClip, confusingly. A "Sprite", is somewhere between a shape and a movie, it is like an autonomous, animated collection of objects generally. They can be made out of shapes, glyphs, bitmaps, text, and other sprites. They can be acted on with Actionscript too IIRC????
- SWFShape. This is the design of a relatively simple shape, almost certainly(?) filled, that you can place instances of in a sprite or a movie. Shapes don't really do a lot, but they're one of the more fundamental drawing primitives.
- SWFDisplayItem SWFDisplayItem. You don't really create "SWFDisplayItem"s yourself directly. Instead, when you add an object (shape, sprite, text etc) to a container (sprite, movie etc), the add method gives you an SWFDisplayItem back. This represents the particular instance of the object within the container, and access to this SWFDisplayItem variable enables you to modify how it is rendered within its container. EG, Z-axis depth, scaling, relative position, rotation, etc etc. Note that when you add a shape to a sprite, the SWFDisplayItem may wind up referring to multiple shapes in the end movie, if multiple sprites are subsequently added to the movie. The manipulation is all relative to the container. NOTE, I should split this bit off into a separate section for clarity.
- SWFFill SWFFill; at least one SWFShape object in your file is almost certainly going to have a fill, unless you only use bitmaps and wireframes and things. You don't create a SWFFill directly, you get it by using the addFill method on a shape, and the n it allows you to alter details of it (if a bitmap or gradient fill) before you use it somewhere in the shape.
These ones are also pretty important!
- SWFAction SWFAction is a piece of Actionscript code? AFAICT these can be treated as objects, to be inserted into containers such as movies or sprites, but it also looks as though you can add them into SWFDisplayItems?? I think that may be a fuckup in the docs, so I shall have to investigate that. I don't quite know the significance is of what containers code goes into, it could be that they're OOPy and work on "this" or "self" etc. As I say, not investigated this much.
- SWFFont SWFFont is used for specifying fonts to SWF. It can wind up as a reference to a browser-based font, which will be system-dependent, or it can be used to embed an external font (in .fdb format) into the file. These can be used by AFAICT any text-using object. Of which there are a few it seems! See also font sources for a list of fonts and details of conversion.
- SWFButton, very useful for interactivity; AFAICT one can get mouse input without these though, via Actionscript. SWFButtons only call SWFAction objects anyway.
- SWFText, for displaying text that isn't to be editable or selectable.
- SWFTextField, for text that is editable/selectable/entered by the user for input. Very important! Seems maybe perhaps a bit more awkward to use than SWFText? OTOH I didn't get very far with it before I switched to trying SWFText, so I should in fact continue experiments to see what is required.
TODO: Make individual pages for the Ming classes, put the list of methods on them and the links to the php docs pages for each.
tips and tricks
Some of these should be put elsewhere later, but meantime:
To send data to and from the server, the actionscript command
loadVariables is ideal. It can send variables to the server in a GET or PUSH fashion, and the variables it loads
back into Flash, can go either into a named sprite "target", or into a concurrently loaded movie "level". The Flash player expects the data loaded from the server to be in URLencoded form data format, which can be produced in PHP via the
http_build_query function. Should remember to send the appropriate header (as named in the dictionary page earlier).
The PHPdocs page for SWFAction, claims that ActionScript doesn't support functions with return, addresses have to be all hardcoded. However the Adobe docs claim that since Flash Player 5, a "return" command has existed for use in functions. The question is, are the docs miserably outdated on this as with everything else, or does Ming simply not support this feature?
This page has the source for the sketchpad app, linking directly to avoid having to load the app itself.
Stuff To Do!
- Make a flash app with a grid, where you click points on the grid to select them, and then when you've got all of the ones you want, you click a "sequence" button to select the order of the ones you picked out. Then you click a "submit" button and it sends that sequence to the server, where it gets stored for later use. That could be by Ming scripts, or SSWF, or swfc from SWFTools, or whatever else, so it should be in a broadly accessible format.
- Make a collaborative flash authoring flash app, where people can make shapes and sprites and gradients etc, and share them in project groups to make bigger things than they reasonably could alone.
- A "flash" tag for mwuki would be nice maybe. Oh, although not to be confused with the tag, [fl] :P Maybe make it a [swf] tag instead.
- Better idea: [swf] tag should be for external SWF files, at a particular URL (should be on this site still! Just not in Mwuki.); Then have [swfm] for Ming-generated SWF files, generated from shapes and crap stored in a special database table, and [swfc] for SWFC-based SWF files, generated from SWFC source in the tag content. The [swfc] tag would have to declare 'childs'=>'' [sic] in the parser definition, so it wouldn't interpret any BBCode tags that happened to be in the source, and they would be sent verbatim to SWFC.
- How these things would be shown is a tricky one, I don't want to blow up the browser. Best thing I think, is set a cookie. If the cookie is absent or says "no flash", don't show embedded flash, show a box with a link to the source or a URL or whatever else, and also with a link to the settings page to change the cookie setting, AND/OR a button that overrides the "no flash" setting temporarily just in order to see it on that page, if that's possible??