Now: Tutorial for Web and Software Design > Flash > Action Script > Flash Content
> Create, Validate and Email a Form in Flash [Bookmark it]
Create, Validate and Email a Form in Flash
Create dynamic text fields in Flash and send them by email.

  1. Create a new document and set the size to 400 x 300 ("Frame" > "Frame Size")
  2. Set "Frame 1" to "Stop" ("Frame" > "Frame Delay" and check "Stop", click OK)
  3. Draw 2 edit fields with the "Edit field" tool, they will appear as Edit1 and Edit2.
  4. Draw a button, double-click it and rename it to "OK".
  5. Draw edit field labels "Phone" and "Email" with the text tool.
  6. Draw "ErrorMessage" field with the text tool. Choose "Item" > "Text Color" and change it to red.

    Click to enlarge
    Click to enlarge

  7. Select the button, choose "Item" > "Actions" > "OnClick". Select "ActionScript" and paste the following code:


// reset error message

ErrorMessage = ""; 



// validate phone field

phone = Edit1;

if(phone=="") ErrorMessage = "Enter your phone";



// validate email field

email = Edit2;

if(email=="") ErrorMessage = "Enter your email";

if(email.indexOf("@",0)<0) ErrorMessage = "Enter valid email";

if(email.indexOf(".",0)<0) ErrorMessage = "Enter valid email";



// build message string

message = "mailto:support@selteco.com?subject=Title&body=Form contents%0A";

message = message + "phone: " + phone + "%0A";

message = message + "email: " + email;



// execute form if errormessage is empty

if(ErrorMessage=="") getURL(message,"_self");

Hit F9 to preview the movie.

This form is using very basic validation. Use "%0A" as line separator.

Use the following functions or attributes of the string:

  • length returns the number of characters
  • charAt(x) returns zero-based character at position x
  • indexOf(substring,startindex) returns the position of the first occurrence of the specified substring or -1.
  • lastIndexOf(substring,startindex) returns the position of the last occurrence of the specified substring or -1.
  • substr(start,n) returns n characters string starting at specified position
  • toLowerCase(), toUpperCase() converts the string to lower or upper case

Download source project t1043.zip (1 kb)


[Bookmark][Print] [Close][To Top]
  • Prev Article-Flash:

  • Next Article-Flash:
  • Related Materias
    Introduction to ActionScri
    Examples of ActionScript 2
    Attaching Movie Clips usin
    Creating the Illusion of S
    Create Flying Hearts Effec
    Smooth Scrollbar
    Typewriter Effect
    Simple Authentication Syst
    Creating Sound Control
    Movie and Image Preloader 
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial