
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Creating a Flash Fill-in Form
|
425
The formInput property of the dataSender object contains the data to be transmit-
ted—the current input of the
input_txt text field, escaped (encoded) for safe net-
work transfer:
dataSender.formInput = escape(input_txt.text);
While the user waits for echo.pl to respond to our form submission, the code dis-
plays a loading message in the
response clip:
form_mc.response.gotoAndStop("loading");
For testing purposes, we display the data to be sent in the Output window, using the
toString() method:
trace("Sending " + dataSender.toString( ));
Finally, we submit the form using sendAndLoad(), instead of send() or load(),
because we’re both sending variables to, and receiving variables from, echo.pl. The
sendAndLoad() method sends
formInput (and any other dataSender properties) to
echo.pl:
dataSender.sendAndLoad("http://www.yourserver.com/cgi-bin/echo.pl",
dataReceiver, "GET");
The sendAndLoad() method takes three parameters: url (the location of the server
script),
targetObject (the LoadVars object that should receive the results), and
method (the HTTP method, either “GET” or “POST”). When sendAndLoad() exe-
cutes,
dataSender’s properties are converted to a single ampersand-delimited string of
variable name/value pairs and sent to echo.pl.
The Perl Script, echo.pl
When ...