Listen Print
Date: December 2002
From: Dan Losak
To: Ask Tim
Subject: Flash MX and CGI

I'm trying to put together a Flash MX and CGI project. I would like to build an input form as a Shockwave file and tailor the action script in it to respond to a Perl/CGI script. What is the best way to do this? Can you recommend any other possible projects in combining these two technologies? And what resources would be best?


When you say "Shockwave," I assume you mean a Flash Player .swf file. Macromedia no longer uses the term "Shockwave for Flash," and a "Shockwave file" now ordinarily refers to "Shockwave for Director," which uses a .dcr file.

You can certainly have ActionScript that communicates with any server-side script, whether written in Perl or another scripting language.

The best way to do this depends on what version of the Flash Player you are targeting.

If you are targeting Flash Player 5, see Chapter 17 of the first edition of ActionScript: The Definitive Guide by Colin Moock. It includes a simple echo example program that does precisely what you seek, using the loadVariables() function to pass data to a Perl script and receive a response in return. You can also use the getURL() function as described in that book's alphabetical Language Reference. If using XML-formatted data, you can use the XML class's sendAndLoad() method, again as described in that book's Language Reference.

If you are targeting the more modern Flash Player 6, you have some more options. The LoadVars class, introduced in Flash MX (i.e., the authoring tool for Flash Player 6 content), is now preferred over the older loadVariables() function.

The new ActionScript for Flash MX: The Definitive Guide, 2nd Edition, due out this month, covers the new preferred methods in detail. Chapter 17 of that book uses the new Flash UI Components to build the input form, and then transmits data using the new LoadVars class. An updated Flash MX version of the echo program is included in the second edition. Other techniques are also discussed throughout the book.

You asked, "Can you recommend any other possible projects in combining these two technologies? And what resources would be best?" It isn't in your best interest to pick a technology and then search for a project that can make use of it. Instead, I'd pick a project that interests you and then find the best solution available. There is no limit to the number of interesting projects you can create using Flash as a front end to some server-side application.

New in Flash MX, Flash Remoting makes it easy for Flash to communicate with ColdFusion MX and consume Web services written in CFML, ASP.NET, Java, etc. Flash Remoting allows transmission of complex ActionScript datatypes, eliminating the slow and cumbersome process of dealing with name/value pairs or serializing/deserializing XML.

The world of Flash, ActionScript, and Flash Remoting is vast and deep. For inspiration, you might consider the Flashforward conference in San Francisco in March 2003.

In the meantime, see the resources listed at Colin Moock's Web site:

Also see Macromedia's site for new product such as Flash Comm Server, which is a realtime communications server for video, chat, etc.

This is definitely an exciting time for Flash and related technologies. Starting with ActionScript for Flash MX: The Definitive Guide will give you a firm foundation on which to expand your technical skills.

Regards,
Bruce Epstein
Associate Editor specializing in Macromedia products

Got a question? Just ask!

Return to: Ask Tim



Popular Topics

Browse Books

News Topics

International Sites

O'Reilly China O'Reilly Germany O'Reilly Japan O'Reilly Taiwan