# TypeError: Error #2007: Parameter text must be non-null. AS3 and PHP

**URL:** <https://forum.kirupa.com/t/typeerror-error-2007-parameter-text-must-be-non-null-as3-and-php/288406>\
**Category:** flash\
**Created:** [May 15, 2009, 10:42am UTC](https://forum.kirupa.com/t/typeerror-error-2007-parameter-text-must-be-non-null-as3-and-php/288406 "2009-05-15T10:42:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![killsteve](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@killsteve](https://forum.kirupa.com/u/killsteve)\
**Post date:** [May 15, 2009, 10:42am UTC](https://forum.kirupa.com/t/typeerror-error-2007-parameter-text-must-be-non-null-as3-and-php/288406/1 "2009-05-15T10:42:09Z")

</div>

Hello everyone, Im very new to flash and im trying to send a contact form. Ive modified a template that was working originally… using flash cs4, actionscript 3 and php  
This is the error I’m getting

```auto
TypeError: Error #2007: Parameter text must be non-null.
	at flash.text::TextField/set text()
	at moviebak_fla::contactus_12/completeHandler()
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/onComplete()

```

Thisis the AS3

```auto
// Set text formatting colors for errors, waiting..., and success mechanisms
var errorsFormat:TextFormat = new TextFormat();
errorsFormat.color = 0xFF0000;

var waitingFormat:TextFormat = new TextFormat();
waitingFormat.color = 0x339900;

var successFormat:TextFormat = new TextFormat();
successFormat.color = 0x3366FF;

// hide the little processing movieclip
processing_mc.visible = false;

// Assign a variable name for our URLVariables object
var variables:URLVariables = new URLVariables();

// Build the varSend variable
var varSend:URLRequest = new URLRequest("http://stevechaffins.com/form.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;

// Build the varLoader variable
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);

// Handler for PHP script completion and return
function completeHandler(event:Event):void {
	    // remove processing movieclip
    processing_mc.visible = false;
    // Clear the form fields
    theName.text = "";
    theEmail.text = "";
	theHome.text = "";
	theCity.text = "";
	theState.text = "";
	theZip.text = "";
	thePhone.text = "";
    theSubject.text = "";
    theMessage.text = "";
	// Load the response from the PHP file
    status_txt.text = event.target.data.return_msg;
	status_txt.setTextFormat(successFormat);
}

// Add an event listener for the submit button and what function to run
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);

// Validate form fields and send the variables when submit button is clicked
function ValidateAndSend(event:MouseEvent):void{
	
    //validate form fields
    if(!theName.length) {	
		status_txt.text = "Please enter your name.";	
		status_txt.setTextFormat(errorsFormat);
	} else if(!theEmail.length) {
        status_txt.text = "Please enter an email address";
		status_txt.setTextFormat(errorsFormat);
	} else if(!validateEmail(theEmail.text)) {
		status_txt.text = "Please enter a VALID email address";
		status_txt.setTextFormat(errorsFormat);
	} else if(!theMessage.length) {
		status_txt.text = "Please enter a message.";
		status_txt.setTextFormat(errorsFormat);
	} else {
	    
		// All is good so send the message to the parse file
		// Show the little "processing_mc" movieclip
        processing_mc.visible = true;
		
		// Ready the variables for sending
  		variables.userName = theName.text;
		variables.userEmail = theEmail.text;
		variables.userHome = theHome.text;
		variables.userCity = theCity.text;
		variables.userState = theState.text;
		variables.userZip = theZip.text;
		variables.userPhone = thePhone.text;
		variables.userSubject = theSubject;
		variables.userMessage = theMessage.text;

		// Send the data to the php file
   		varLoader.load(varSend);
		
		// Put a temporary message in the response field while the PHP file sends back
		// If the code does not connect to the PHP file this message will remain visible to user
		status_txt.text = "Waiting for server connection...";
        status_txt.setTextFormat(waitingFormat);

	} // close else after form validation

} // Close ValidateAndSend function //////////////////////////////////////////////////////////////

// Validate email function
function validateEmail(str:String):Boolean {
	var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
	var result:Object = pattern.exec(str);
	if(result == null) {
		return false;
	}
	return true;
}
////////////////////////////////////

```

and my php…

```php
<? 
/*
             --- Created by Adam Khoury @ www.developphp.com ---

*/
// Create local variables from the Flash ActionScript posted variables
$senderName = $_POST['theName'];
$senderEmail = $_POST['theEmail'];
$senderHome = $_POST['theHome'];
$senderCity = $_POST['theCity'];
$senderState = $_POST['theState'];
$senderZip = $_POST['theZip'];
$senderPhone = $_POST['thePhone'];
$senderSubject = $POST['theSubject']
$senderMessage = $_POST['theMessage'];

// Strip slashes on the Local variables for security
$senderName = stripslashes['$senderName'];
$senderEmail = stripslashes['$senderEmail'];
$senderHome = stripslashes['$senderHome'];
$senderCity = stripslashes['$senderCity'];
$senderState = stripslashes['$senderState'];
$senderZip = stripslashes['$senderZip'];
$senderPhone = stripslashes['$senderPhone'];
$senderMessage = stripslashes['$senderMessage'];

// IMPORTANT - Change these lines to be appropriate for your needs - IMPORTANT
$to = "steve@gmail.com";			 
$from = "$senderEmail";
$subject = "$senderSubject";
// Modify the Body of the message however you like
$message = "Message from your website:

Their Name: $senderName 

Their Email: $senderEmail
	
Their Phone: $senderPhone
	
Their Home Address: $senderHome
	
City, State, and Zip: $senderCity, $senderState, $senderZip
	
Their Message is below: 

$senderMessage";
// Build $headers Variable
$headers = "From: $from
";
$headers .= "Content-type: text
"; 
$to = "$to";
    // Send the email
    mail($to, $subject, $message, $headers);
	
	// Assemble the message that goes back to Flash
	// The flash ActionScript is looking for a return variable of "return_msg"
	$my_msg = "Thanks $senderName, your message has been sent.";
	// Print the data back to flash who is patiently waiting for it in the onCompleteHandler
    print "return_msg=$my_msg"; 
// Exit script	
exit();
?>

```

as i said im very new so please excuse me if ive left anything important out… thank you in advance…
