A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5848 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


Random Links | Add your own Flash Related Links
Flash Tutorials 1277 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Trading Customer Accounting (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Dynamic_Content

Categories E-mail in Flash the Easy way
Author: Jeffrey F. Hill | Website: http://www.flash-db.com |

 
Page 4
«prev 1 2 3 4 5 6 7 8 next»

Part I - Setting up the Form in Flash

Begin setting up the Flash form by creating text fields that will contain the information that you want to send.  The most basic fields are the Name, E-mail, and Comments fields.  Create each text field that you want to use as an "Input Text" field.  Then give each one a unique name.  Set the Max Chars option to a number  you think should be the maximum number of characters allowed for each field.

To create hidden information that is passed to the script and eventually the e-mail,  all you have to do is set a variable.  For example you can set a unique Subject line in each e-mail you send by creating a variable named Subject. Another example would be if you wanted to set a different destination e-mail address for each occurrence of the form.  This is important if you want to be able to use the same exact form to be able to send different e-mails in different locations in the main Flash movie.  And then give it a value.  Here's an example:

Subject = "This is the Subject";
ToEmail = "joeBob@example.com";

These variables must be located on the same level in the same movie clip as the rest of the text fields.   Additionally, the button that will eventually call the script and send the information to your server and on to the specified e-mail, must reside at that same level. 

You can set up the form as either a separate movie clip located somewhere in the main movie or just on the _root level of the movie.  I would recommend setting it up as a self contained Movie clip so you could use it over and over in many different places in the movie - or in future projects.   To make everything easier, as mentioned earlier, try to keep all the text fields and hidden variables on the same level in the same Movie Clip.  This is however not necessary - you can use information, for example the e-mail address of the sender, from other parts of the script - you just have to get the paths right.  For example say you are sending the information from a movie clip called Mail and the user has already entered his/her e-mail in the main movie on the _root level.  You can automatically fill out the text field named E-mail by using the code Email = _root.Mail.Email; in the Movie Clip Mail.  Ok sounds confusing but it's really not, after a short time of messing around with it and trying different solutions you'll get it. 

We will now create a dynamic text field named EmailStatus.  This text field will be used to show messages to the user on the progress or status of their e-mail.  You can also use this text field to display eror messages to the user, for example if they did not fill out one of the fields or they are not using a valid e-mail address. 

For the next part of creating the form - create a button and label it SendMail or something similar.  Place this in the same Movie clip as the rest of your Input text Fields.  Then attach the following code to it:

on (release) {
 if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
 EmailStatus = "Please enter a valid E-mail address";
 }
 else if (!FirstName.length) {
 EmailStatus = "Please Enter your name before Sending";
 }
 else if (!ToComments.length) {
 EmailStatus = "Please enter some text in you message";
 }
 else {
 loadVariablesNum ("snowMailPHP.php", "0", "Post");
 EmailStatus = "Sending... one Moment .. or two.. sometimes it's faster then other times";
 }
}

This code checks to make sure that all the input fields/variables have been filed out.  In the case of the Email, it checks to make sure that it is a valid e-mail address.  It checks for an @ symbol and a '.' symbol.  Hopefully by looking over the code you will be able to use this same method for any other input fields/variables you want to be sent to an e-mail address.  Note - this is not necessary, the only really important part of the above code is the "loadVariablesNum ("snowMailPHP.php", "0", "Post");" line.  Also note that this is the one line that you will have to change if you are going to be using something other then PHP to send the mail.  If you are using Perl, instead the line would read:  "loadVariablesNum ("http://www.yoursite.com/cgi-bin/snowMailPerl.cgi", "0", "Post");"  Or with ASP - "loadVariablesNum ("ASPMail.asp", "0", "Post");"

 Note: In the online example there are two extra fields named 'ToMail' and 'ToName' - These variables allow you to send an e-mail to anyone you want to.  Basically it's an anonymous e-mailer - There are a couple of precautions built in to discourage abuse of it in the actual example - but not in the attached downloadable documentation.  However you should not set up your Mail form in this way.   Always make the ToEmail hard coded into the script that you are using (or a hidden variable in the Mail Movie Clip). This will be shown later in this tutorial.   

That's all there is to the Flash part - now on to the exciting part - setting up the server side scripts. 

«prev 1 2 3 4 5 6 7 8 next»

» Level Advanced

Added: : 2001-08-27
Rating: 8.79 Votes: 327
Hits: 12937
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (67 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs