
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Creating a Flash Fill-in Form
|
427
If we give dataSender another property, country, with a value of “Canada”, then
echo.pl creates the string:
output=formInput:theInputValue\ncountry:Canada
3. It returns the string to Flash.
When Flash receives the string from echo.pl, it finds the
output variable and automat-
ically adds a corresponding
output property on dataReceiver. The value of the output
property is the string containing the list of variables we sent to echo.pl.
Obviously, echo.pl is merely a proof of concept. When applied, however, the con-
cept can have interesting and powerful results. For an example of a more fully devel-
oped Perl system, see the flat file database sample available under “Server
Communication” at the online Code Depot.
Receiving Results from the Server
Recall that when we sent the properties of dataSender to echo.pl, we requested that
echo.pl’s return value be stored in the
dataReceiver object:
dataSender.sendAndLoad("http://www.yourserver.com/cgi-bin/echo.pl",
dataReceiver, "GET");
When data is received from echo.pl, Flash executes the callback assigned to
dataReceiver.onLoad( ). We originally assigned that callback inside our initForm( )
function in Example 17-1; let’s take a closer look at it now:
dataReceiver.onLoad = function ( ) {
// Prepare the response clip ...