Ming Perl HOWTO and Examples        -- 31 Jan 2002, Tod E. Kurt, todbot.com
- A quick description of getting Ming Perl running

With Ming Perl, one can use Perl to write SWF ("Flash") movies.
The amazingly coolness of this I cannot even begin to express.
Disclaimer: I'm just a user of Perl Ming, not a Ming developer.

News: (last updated: 12 Mar 2003)

Ming is a very well-written C library for generating Flash movies, by Dave Hayden.
Most people think of it as just a PHP libary. It's not. It's much more. Find it at: http://opaque.net/ming/

Ming Perl is a Perl XS wrapper around the Ming C library, by Soheil Seyfaie.
Perl Ming is included as part of Ming, but hardly anyone ever talks about it.

Since I couldn't find any talk about the Perl side of Ming, I decided to put up this page. The main things that seemed to be lacking in the evangalization of Perl Ming was:

  • Step-by-step instructions on getting Perl Ming running
  • Perl versions of the examples in 'ming-examples'
  • Hints on how to transcode Ming PHP to Ming Perl
My takes on the first two are linked on the right. As for the third, well....

PHP Perl


  $f = new SWFFont("../common/test.fdb");
  $t = new SWFText();
  $t->moveTo(200, 2400);
  $t->setColor(0xff, 0xff, 0);
  $t->addString("fnar! fnar!");

  $m = new SWFMovie();
  $m->setDimension(5400, 3600);


#!/usr/bin/perl -w
use strict;

use SWF qw(:ALL);

my $f = new SWF::Font("../common/test.fdb");
my $t = new SWF::Text();
$t->moveTo(200, 2400);
$t->setColor(0xff, 0xff, 0);
$t->addString("fnar! fnar!");

my $m = new SWF::Movie();
$m->setDimension(5400, 3600);



Not too different, huh?
It turns out that both the syntax and the usage of Ming Perl is very similar to Ming PHP. That means all of us Perlmongers can just look at the Ming examples and transcode them with hardly a brain.

As a larger example of this transcoding, ming-pong.pl is a Perl translation of Armel Grignon's nifty Ming-Pong game tutorial seen on http://www.neuralust.com/~mingdocs/. And here is the SWF that is output by the above script. Check out all of Armel's tutorials and Jerry Jasuta's lessons on mingdocs, they're very good.

The only semantic change that had to be made is that in Perl the first argument to 'SWF::Shape->setLine()', the 'width', doesn't seem to use 'SWF::setScale()' like PHP version of the command.

There are some other odd differences between the two, mostly due to Perl<->C data type conversions or dealing with Perl's data struct allocs I think. Doing things like this:
 my $p = new SWF::Morph();
 my $s = $p->getShape1();
 # ... do stuff to '$s' shape1 ...
 $s = $p->getShape2();
 # ... do stuff to '$s' shape2 ...
will cause a core dump. Instead, just call it '$s1' and '$s2' and Bob's your uncle. This doesn't bug me too much currently, but such brittleness does probably eliminate it's use in mod_perl.

Okay, enough of the feverish rambling.
Let me know (todnope@nopetodbot.com) if you have any comments or questions.



  • Ming-Perl-Mini-HOWTO.txt
  • ming-examples-perl.tar.gz
  • ming-examples/perl/
         - tarball exploded
  • ming-pong.pl

  • links:

  • Ming homepage
  • Ming PHP examples
  • Mingdocs site (PHP)
         - Ming Pong, the original
         - 'getting-started' lessons
  • Ming CVS

  • ActionScript-Toolbox.com
  • Macromedia ActionScript info
  • Flash ActionScript Dictionary

  • Page layout unabashedly stolen from 'http://opaque.net/ming/'.

    Ming is Copyright (C) 2000-2001 Opaque Industries except where noted otherwise.

    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. Neither any ancient Chinese dynasties.