# as3 contact form: null object reference

**URL:** <https://forum.kirupa.com/t/as3-contact-form-null-object-reference/287815>\
**Category:** flash\
**Created:** [May 6, 2009, 4:37pm UTC](https://forum.kirupa.com/t/as3-contact-form-null-object-reference/287815 "2009-05-06T16:37:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![j\_polo9](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j\_polo9](https://forum.kirupa.com/u/j_polo9)\
**Post date:** [May 6, 2009, 4:37pm UTC](https://forum.kirupa.com/t/as3-contact-form-null-object-reference/287815/1 "2009-05-06T16:37:22Z")

</div>

I am getting the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at MySite\_fla::contactForm\_8/sendForm()

Any idea what the null object reference is is the sendForm() method?

Thanks,  
-Jesse

```auto

//---------------Setup variables
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("contact.php");
var variables:URLVariables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
//--------------Set tab index
first_name_txt.tabIndex = 0;
last_name_txt.tabIndex = 1;
address_txt.tabIndex = 2;
city_txt.tabIndex = 3;
state_txt.tabIndex = 4;
zip_txt.tabIndex = 5;
phone_txt.tabIndex = 6;
email_txt.tabIndex = 7;
message_txt.tabIndex = 8;
send_button.tabIndex = 9;
reset_button.tabIndex = 10;
//--------------Set listener fot textfield changes
first_name_txt.addEventListener(Event.CHANGE, txErrorCheck);
last_name_txt.addEventListener(Event.CHANGE, txErrorCheck);
address_txt.addEventListener(Event.CHANGE, txErrorCheck);
city_txt.addEventListener(Event.CHANGE, txErrorCheck);
state_txt.addEventListener(Event.CHANGE, txErrorCheck);
zip_txt.addEventListener(Event.CHANGE, txErrorCheck);
phone_txt.addEventListener(Event.CHANGE, txErrorCheck);
email_txt.addEventListener(Event.CHANGE, txErrorCheck);
message_txt.addEventListener(Event.CHANGE, txErrorCheck);
function txErrorCheck(event:Event):void {
 if (txError.text.length>0) {
  txError.text = "";
 }
}
//--------------Set up form buttons
send_button.addEventListener(MouseEvent.CLICK, sendForm);
reset_button.addEventListener(MouseEvent.CLICK, resetForm);
//--------------Validate fields and submit form
function sendForm(evt:MouseEvent):void {
 if (first_name_txt.text.length<=0) {
  txError.text = " **First Name Required**";
 } else if (!email_txt.text.length || email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
  txError.text = "missing field/Invalid email";
 } else if (message_txt.text==""||message_txt.text.length<=1) {
  txError.text = " **Message Required**";
 } else {
  this.gotoAndPlay("wait");
  variables.senderFirstName = first_name_txt.text;
  variables.senderLastName = last_name_txt.text;
  variables.senderAddress = address_txt.text;
  variables.senderCity = city_txt.text;
  variables.senderState = state_txt.text;
  variables.senderZip = zip_txt.text;
  variables.senderPhone = phone_txt.text;
  variables.senderEmail = email_txt.text;
  variables.senderMsg = message_txt.text;
  req.data = variables;
  loader.load(req);
  loader.addEventListener(Event.COMPLETE, receiveLoad);
 }
}
function receiveLoad(evt:Event):void {
 if (evt.target.data.retval == 1) {
  this.gotoAndStop("output");
 } else {
  this.gotoAndStop("error");
 }
}
//--------------Reset form
function resetForm(evt:MouseEvent):void {
 first_name_txt.text="";
 last_name_txt.text="";
 address_txt.text="";
 city_txt.text="";
 state_txt.text="";
 zip_txt.text="";
 phone_txt.text="";
 email_txt.text="";
 message_txt.text="";
}
stop();

```

[www.norcaldesigns.com](http://www.norcaldesigns.com)  
Roseville Website Design.
