I’ve been experimenting with dynamically generating Flash SWF files this afternoon, using Ming and the Ming/Ruby library.

Since the Mac OS X installation was slightly non-trivial, I think it’s useful to note it down here.

This assumes that you are using Ruby from MacPorts (née Darwin Ports).

First, install some library dependencies:

sudo port install libpng zlib libungif

If you get an error like ‘Another version of blah is already active’, don’t worry: just remove it from the install line above and try again.

Download version 0.3.0 of the Ming library and extract it.

cd ming-0.3.0/
./configure "LDFLAGS=-L/opt/local/include -L/opt/local/lib" \
"CPPFLAGS=-I/opt/local/include -I/opt/local/lib" \
"CFLAGS=-I/opt/local/include -I/opt/local/lib"
make
sudo make install

Get Ming/Ruby 0.1.8 and extract it.

cd ming-ruby-0.1.8/
sudo ruby setup.rb

If all that worked, you can try a ‘Hello World’ example. The best source for documentation is at the delightfully-named Ming the Manual, although you’ll have to use your initiative to translate the method calls into Ruby (hint: change methodsLikeThis to methods_like_this).