Skip to main content
Participant
November 14, 2013
Answered

ActionScript 3 + PHP: TypeError: Error #2007: Parameter text must be non-null.

  • November 14, 2013
  • 1 reply
  • 1462 views

Hi - Still new to flash as3 and php -

it is a contact form page - user puts in information - i am to receive it in an email address their information

as well the variables get sent back from the php to the .swf file.

I am receiving these errors and not knowing how to fix them.

any help would be much appreciated. thank you in advance really.

below are the errors in flash - as3 code - and php code setup.

errors:

ActionScript 3 + PHP: TypeError: Error #2007: Parameter text must be non-null:

  at flash.text::TextField/set text()

          at kwangjaekim_fla::wholeform_16/completeHandler()

          at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()

          at flash.events::EventDispatcher/dispatchEvent()

          at flash.net::URLLoader/flash.net:URLLoader::onComplete()

my as3 code is the following:

// build variable name for the URL Variables loader

var variables:URLVariables = new URLVariables();

//Build the varSend variable

var varSend:URLRequest = new URLRequest("contact_parse.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 the PHP  script completion and return of status

function completeHandler(event:Event):void{

          //value is cleared at ""

          name_txt.text = "";

          contact_txt.text = "";

          msg_txt.text = "";

 

          //Load the response PHP here

          status_txt.text = event.target.data.return_msg;

}

//Add event listener for submit button click

submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);

//function ValidateAndSend

function ValidateAndSend(event:MouseEvent):void{

          //validate fields

          if(!name_txt.length){

                    status_txt.text = "Please Enter Your Name";

          }else if(!contact_txt.length){

                    status_txt.text = "Please Enter Your Contact Detail";

          }else if(!msg_txt.length){

                    status_txt.text = "Please Enter Your Message";

          }else {

 

          // ready the variables in form for sending

  variables.userName = name_txt.text;

          variables.userContact = contact_txt.text;

          variables.userMsg = msg_txt.text;

 

          // Send the data to PHP now

varLoader.load(varSend);

 

submit_btn.addEventListener(MouseEvent.CLICK, function(){MovieClip(parent).gotoAndPlay(151)});

          } // Close else condition for error handling

} // Close validate and send function

my php code is the following:

<?php

// Create local PHP variables from the info the user gave in the Flash form

$senderName   = $_POST['userName'];

$senderEmail     = $_POST['userContact'];

$senderMessage = $_POST['userMsg'];

// Strip slashes on the Local variables

$senderName   = stripslashes($senderName);

$senderContact     = stripslashes($senderContact);

$senderMessage   = stripslashes($senderMessage);

//!!!!!!!!!!!!!!!!!!!!!!!!!     change this to my email address     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                          $to = "put iny me email address";

     // Place sender Email address here

    $from = "$senderContact ";

    $subject = "Contact from your site";

    //Begin HTML Email Message

    $message = <<<EOF

<html>

  <body bgcolor="#FFFFFF">

<b>Name</b> = $senderName<br /><br />

<b>Contact</b> = <a href="mailto:$senderContact">$senderEmail</a><br /><br />

<b>Message</b> = $senderMessage<br />

  </body>

</html>

EOF;

   //end of message

    $headers  = "From: $from\r\n";

    $headers .= "Content-type: text/html\r\n";

    $to = "$to";

    mail($to, $subject, $message, $headers);

 

exit();

?>

thank you once again

jay

This topic has been closed for replies.
Correct answer Ned Murphy

As I mentioned, the PHP is not returning the value you are trying to assign to the text property of  the status_txt textfield.  So you are trying to assign an undefined value to it.  Somewhere in your PHP you need to echo that value....

       echo "return_msg=whatever the message is";

1 reply

Ned Murphy
Legend
November 14, 2013

I don't see where the PHP code provides any return value.  Use the trace function one line before to see what you are getting for the return value....

function completeHandler(event:Event):void{

          //value is cleared at ""

          name_txt.text = "";

          contact_txt.text = "";

          msg_txt.text = "";

 

          //Load the response PHP here

          trace("returns: " + event.target.data.return_msg)

          status_txt.text = event.target.data.return_msg;

}

Kwang JaeAuthor
Participant
November 15, 2013

thank you Ned -

i put in the trace line as you mentioned -

and this is what i received -

returns: undefined

TypeError: Error #2007: Parameter text must be non-null

          at flash.text::TextField/set text()

          at kwangjaekim_fla::wholeform_16/completeHandler()

          at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()

          at flash.events::EventDispatcher/dispatchEvent()

          at flash.net::URLLoader/flash.net:URLLoader::onComplete()

what does this mean exactly?

thank you for the help really

Ned Murphy
Ned MurphyCorrect answer
Legend
November 15, 2013

As I mentioned, the PHP is not returning the value you are trying to assign to the text property of  the status_txt textfield.  So you are trying to assign an undefined value to it.  Somewhere in your PHP you need to echo that value....

       echo "return_msg=whatever the message is";