First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Thomas Watson | Website:

Ok... here's goPostal and it kicks off everything we've discussed so far about our functions. Remember this is the click handler for the "Send Mail" (submit) button.

When the user clicks "Send Mail" the first thing we do is check to see if they gave us their name with the ckName function. We've set up the message box parameters in ckName, so if it returns false, all we have to do is display the message box and exit goPostal which we do with the return. The message box is on the screen now, telling the user they must enter their name, and is being held there by the "OK" button. When the user clicks that button, they can then enter their name before clicking "Send Mail" to try again. If ckName returns true, we continue along in goPostal.

The function ckMail works the same way. When we call that function, if it returns false, we give them the message box we set up in the ckMail function and exit from goPostal. Otherwise, we continue.

Once we know we have some data for name and email, we set up the message box with a new icon, title, and message, telling the user that we're sending their mail. We then make the box visible on the screen, and then immediately disable it. This keeps them from clicking "OK" which would take us back to goPostal before we're ready. Remember we have to wait to see if sendAndLoad was successful or not.

Now we call sendAndLoad which sends the data to the server as previously described, and hopefully loads the returned data. Note we give it three parameters-- the URL of our PERL script to invoke, the loadVars object which is to receive the data Loaded from the server, and the sending method, either "get" or "post" with "post" being the default value. When it's process is complete, it then calls our onLoad event handler and the appropriate message box is once again displayed simply by changing the message box parameters in the onLoad" function.

Now that you have the form designed and all the scripting in place, upload the PERL script to the server and using Control->Test Movie see how you did. Intentionally leave the name field blank, click "Send Mail," and you should get a screen that basically looks like this:

Just a quick note on the PERL script-- it's attached here and can easily be hacked for your own usage. If you're not a whiz at PERL, I've commented liberally so you should be able to follow what's going on there. Remember to chmod to "755." This is a very simple script and does not rely on any installed libraries, and should even work with old versions of PERL. This tutorial is not really about the scripting and it's only included as a convienience. The Flash implemented here will work equally well with PHP and ASP scripts if that's your preference.

» Level Intermediate

Added: 2002-05-07
Rating: 9 Votes: 81
(10 being the highest)
» Author
Tom Watson is a Flash developer currently residing in Nashville, Tennessee. He's been an independant contractor in the computer business since 1989, working on web projects since the web was introduced to the Internet in 1994.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.