<?xml version="1.0" encoding="windows-1252"?>
<node id="324638" title="Flash graphics with perl: installing ming" created="2004-01-28 06:14:25" updated="2005-08-15 11:48:23">
<type id="956">
perltutorial</type>
<author id="324092">
Sol-Invictus</author>
<data>
<field name="doctext">
First things first, you need Ming, available &lt;a href="http://www.opaque.net/ming/"&gt;here&lt;/a&gt;.
&lt;p&gt;
Inside the distro are various wrappers for the library, including a little publicised perl one. Install the perl wrapper using the standard proceedure for perl modules:
&lt;p&gt;
perl Makefile.PL&lt;br&gt;
make&lt;br&gt;
make test&lt;br&gt;
make install&lt;br&gt;
&lt;p&gt;
In my case I got some errors see foot note&lt;i&gt;(1)&lt;/i&gt; if you like that sort of thing, but I forced the install with no obvious problems. Darwin/OSX users also see foot note &lt;i&gt;(2)&lt;/i&gt; for applying a patch to the makefile. 
&lt;p&gt;
&lt;p&gt;
Next, Ming needs  a special font definition for each font used (the test script below uses "serif.fdb"). These files can only be generated by (the very expensive) flash editor apps, luckily we get out of catch22 thanks to the author of &lt;a href="http://www.oreilly.com/catalog/perlgp/index.html"&gt;Perl Graphics Programming&lt;/a&gt;, who has a .fdb file on his web site: &lt;a href="http://shawn.apocabilly.org/PGP/examples/serif.fdb"&gt;serif.fdb&lt;/a&gt; and the kindness of ming enthusiasts who keep a goodly list &lt;a href="http://www.dataturn.com/mingdocs/fonts/getfonts.htm"&gt;here&lt;/a&gt;
&lt;p&gt;
Now we can start creating our own whistles and bells - but with perl:
&lt;p&gt;
&lt;pre&gt;&lt;tt class="code"&gt;&lt;font size="-1"&gt;#!/usr/bin/perl -w
use strict;
use SWF qw(:ALL);

my($font,$movie,$text);


SWF::setScale(1.0);

$font = new SWF::Font(&amp;quot;/path/to/serif.fdb&amp;quot;);
$text = new SWF::Text();
$text-&amp;gt;setFont($font);
$text-&amp;gt;moveTo(200, 2400);
$text-&amp;gt;setColor(0xff, 0xff, 0x99);
$text-&amp;gt;setHeight(1000);
$text-&amp;gt;addString(&amp;quot;It works!&amp;quot;);

$movie = new SWF::Movie();
$movie-&amp;gt;setDimension(5400, 3600);

$movie-&amp;gt;add($text);

$movie-&amp;gt;save(&amp;quot;/path/to/SWFtest.swf&amp;quot;);
&lt;/font&gt;&lt;/tt&gt;&lt;/pre&gt;

&lt;p&gt;
&lt;p&gt;
&lt;SMALL&gt;
Foot notes: &lt;p&gt;
&lt;p&gt;
1) Make test output:&lt;br&gt;
&lt;pre&gt;
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"  
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_basic....ok
t/01_shape....ok
t/03_movie....ok
t/button......ok
t/drag........ok
t/fill........ok
t/filljpeg....Test header seen more than once!
t/filljpeg....FAILED tests 1-2
         Failed 2/2 tests, 0.00% okay
t/gradient....ok
t/png.........Test header seen more than once!
t/png.........FAILED test 1
         Failed 1/1 tests, 0.00% okay
t/sound.......Test header seen more than once!
t/sound.......FAILED tests 1-3
         Failed 3/3 tests, 0.00% okay
t/sprite......ok
Failed Test  Stat Wstat Total Fail  Failed  List of Failed
------------------------------------------------------------------------ 
-------
t/filljpeg.t                2    2 100.00%  1-2
t/png.t                     1    1 100.00%  1
t/sound.t                   3    3 100.00%  1-3
Failed 3/11 test scripts, 72.73% okay. 6/26 subtests failed, 76.92%  
okay.
make: *** &amp;#91;test_dynamic&amp;#93; Error 2
&lt;/pre&gt;

&lt;p&gt;
2) Intsructions for Darwin/OSX patch:&lt;br&gt;
 &lt;p&gt;
get the patch &lt;a href="http://www.haque.net/software/patches/ming-0.2a-mhaque-darwin-jaguar.patch.gz"&gt;here&lt;/a&gt;
&lt;p&gt;
In the terminal make sure the patch, and you, are in the ming directory and type:
&lt;p&gt;
&lt;pre&gt;&lt;tt class="code"&gt;&lt;font size="-1"&gt;'zcat ming-0.2a-mhaque-darwin-jaguar.patch.gz | patch -p0' 
&lt;/SMALL&gt;&lt;/tt&gt;&lt;/pre&gt;

&lt;p&gt;
This will patch the makefile to install both dynamic and static ming libs correctly.
&lt;/p&gt;
&lt;p&gt;
</field>
</data>
</node>
