Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there some simple practical instructions how to make flash animation (Ming Perl) like:

http://todbot.com/ming/ming-examples/perl/animation.swf
Does this animation is intended work only on cgi supported hosting service?

Replies are listed 'Best First'.
Re: Flash animation
by ikegami (Patriarch) on Oct 01, 2004 at 18:03 UTC

    The Ming documentation

    I was able to download the .swf file you linked and play it locally, so no, CGI is not used.

Re: Flash animation
by Your Mother (Archbishop) on Oct 01, 2004 at 20:57 UTC

    Flash is driven by ActionScript which is a language that reads quite a bit like JavaScript. The reason why it works for anyone is b/c they have the interpreter downloaded to their computer (and usually plugged into their browsers). To make something that acted like Flash but was driven by Perl, you'd have to write a mini-interpreter, probably as a plugin for every browser out there, and get the remote users to download and install it. Online life moves so fast it's easy to forget that just a few years ago practically no one had Flash plugins and there was quite a bit of resistance to Flash's continued existence.

    So, the short answer is: no way. To make a similar kind of animation with Perl would be a monumental undertaking that would be recreating the work of hundreds of developers over several years; and it would only be an academic exercise b/c Flash (and Shockwave) have the market sewn up and getting everyone to download one more plugin would be unlikely. Even when your product is much better (eg, Quicktime vs the Windows and Real alternatives) you face enormous challenges to adoption.

    update: color me wrong. See SWF::Builder.

Re: Flash animation
by zentara (Cardinal) on Oct 02, 2004 at 13:46 UTC
    The best way to learn how use it is to play with it. Here are some of the tricks I've discovered, but YMMV.

    One of the big problems I've seen, is the difference in extensions which the mozilla flash plug-in recognizes, for you to open them locally. One is .swf and the other is .spl. So when you want to generate and play the flash files you create with Ming locally, try saving the output as .swf and .spl and try to open them with your browser and see which work. Remeber to take the "Context-type..." line out of the script if you are trying to create standalone files.

    For instance if you want to make a japh.swf file, you would do something like:

    my_mingscript > japh.swf #and then in your html put <html> <body> <center> <embed src="japh.swf" width="100%" height="100%" play="true"loop="true +" quality="high" scale="EXACTFIT"> </center> </body > </html>
    Now if you want to output the cgi directly, you can do it
    #!/usr/bin/perl use strict; use SWF qw(:ALL); SWF::setScale(1.0); print "Content-type: application/x-shockwave-flash\n\n"; my $s = new SWF::Shape(); my $b = new SWF::Bitmap('/home/soheil/src/ming-0.0.9/examples/common/b +ackyard.jpg'); my $f = $s->addFill($b); $s->setRightFill($f); $s->drawLine(640, 0); $s->drawLine(0, 480); $s->drawLine(-640, 0); $s->drawLine(0, -480); my $m = new SWF::Movie(); $m->setDimension(640, 480); $m->add($s); $m->output();

    Finally, go to some flash websites that you like, and look at the html source to see how they embed their .swf file.


    I'm not really a human, but I play one on earth. flash japh
Re: Flash animation
by Anonymous Monk on Oct 01, 2004 at 22:19 UTC

    I went to the parent directory http://todbot.com/ming/ming-examples/perl/ and looked at the source code of your Flash example.

    This does not run in CGI. Instead the Flash file is created programmatically offline and then, presumably, uploaded manually, like one would do with traditional image or animation files.

    Although technically there's no reason why those files could not be created on the fly in CGI or mod_perl.