Constructors

Methods

ContactForm class

ContactForm

extends EventDispatcher

 

 

Overview

Author

Matt Przybylski [http://www.reintroducing.com]

Version

1.0

Description

Creates a communication gateway between a contact form and a PHP script that checks for validity and sends the email. The e-mail checking is rudimentary at best, but it gets the job done. If someone will go through the trouble to try and break this e-mail checker, then by all means spam away (at least that's the way I see it).

The fields array should contain an object for each field. The object will have a "field" string value, which is the instance name (minus the "_txt" suffix) of the text field to check, an "error" string value which is the error text that is displayed when the error events are dispatched, and a "required" boolean that checks if the field is a required field.

As of right now, the fields that are passed into the fields array should be written as the instance name of the field minus the _txt extension. For example, if the instance name is name_txt, you pass "name" as the field string value in the fields array.

The class dispatches a custom ContactFormEvent depending on what happens. The events are as follows:

  • ContactFormEvent.ON_EMAIL_ERROR: Dispatched if the e-mail check returns an incorrect e-mail address (params object contains field name, error text, and error ID)
  • ContactFormEvent.ON_INVALID_ERROR: Dispatched when a required field fails the check (params object contains field name, error text, and error ID)
  • ContactFormEvent.ON_SUCCESS: Dispatched when the message has been successfully sent
  • ContactFormEvent.ON_FAILED: Dispatched if the server is unable to deliver the message (params object contains IOErrorEvent)

Constructors

 

ContactForm

Usage

public function ContactForm($fields:Array, $scriptURL:String, $email:String, $subject:String):void

Description

Creates a new instance of the ContactForm class. The events ContactFormEvent.ON_EMAIL_ERROR and ContactFormEvent.ON_INVALID_ERROR will be dispatched if there is an error with the e-mail field or any other required field. The errors that will be shown are defined in the fields array.

Parameters

$fields
An array that tells the form what fields to check, what errors to display, and if the field is required or not
$scriptURL
A string that represents the path on the server to the PHP script
$email
A string representing an e-mail address that the script will send the information to
$subject
A string representing the subject of the e-mail being sent

Methods

 

sendMessage

Usage

public function sendMessage($timeline:MovieClip):void

Description

Checks the form and dispatches the appropriate event according to what is happening.

Parameters

$timeline
The timeline that the fields/clips for the form are located on

Returns

void