• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 13. Validating Data > Processing Validated Data

Processing Validated Data

The last task for our application is to send all the validated data to a server for processing. We'll use a LoadVars object to accomplish this goal.

Open validate6.fla.

We'll continue building on the project from the preceding exercise.

With the Actions panel open, select Frame 1 of the Actions layer and add the following script at the top of the current script, just below the stop() action:

var registrationData:LoadVars = new LoadVars();

This creates a new LoadVars object named registrationData. In the next step we will add a script that places our validated data into this object and sends it to the server.

Add the following script to the else leg of the validateForm() function:

registrationData.name = name_ti.text;
registrationData.email = email_ti.text;
registrationData.state = state_ti.text;
registrationData.zip = zip_ti.text;
registrationData.sendAndLoad("http://www.myDomain.com/registration.php", registrationData, "POST");


When all the data entered into the form is valid, the actions in the else part of the validateForm() function—including this section of script—are executed.

The first four lines of the script place the data in the various TextInput instances into the registrationData object. The last line sends this data to a server-side script.


For the last line of script, you should insert the URL to a script on your server for processing the data. Or, if you simply want to do a final test of your code, use this URL: http://www.derekfranklin.com/cftemplates/notsosoft.cfm. The ColdFusion page at this URL will send you email containing the validated data.

The else part of this script already had an action that would send the application to the Confirm label automatically when all the data entered was valid. Because the application is now set up to send data to a server, let's change this functionality a bit so that the application only moves to that frame label after a response has been received from the server, indicating that the submitted data has been received and processed.

Remove the line of script in the else leg of the validateForm() function that reads gotoAndStop("Confirm") and insert the following script just above the sendAndLoad() method call:

registrationData.onLoad = function(){

This script will move the application to the Confirm label when a server response has been sent back to the registrationData object. Let's do one final test.


Before testing, make sure that the URL specified in the sendAndLoad() method discussed in Step 3 contains a server-side script for handling the incoming data.

Choose Control > Test Movie.

If you enter valid data into the form fields and click the Submit button, the application should send the data to the specified server-side script for processing, and eventually move the application's timeline to the Confirm label after a response has been received from the server.

Close the test movie to return to the authoring environment, and save this file as validate7.fla.

This step completes the exercise and this lesson. The great thing about the way we've set up this project's validation process is that it's dynamic. To analyze additional rules or validation points for any of the text fields, all you have to do is add more conditional statements to the appropriate function. The validation process can grow as your needs grow.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint