Skip to main content
Known Participant
December 4, 2014
Answered

AS3 Error

  • December 4, 2014
  • 2 replies
  • 2128 views

Hello I am creating a contact form in Flash with AS3 and I am getting this error message:

Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:///Macintosh%20HD/Users/animationmanx/Desktop/mail.php

  at ContactMovie_fla::MainTimeline/sendMessage()

Here is the code

<?php

$to = "myemailHere.com";

$subject = ($_POST['senderName']);

$message = ($_POST['senderMsg']);

$message .= "\n\n---------------------------\n";

$message .= "E-mail Sent From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";

$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";

if(@mail($to, $subject, $message, $headers))

{

echo "answer=ok";

}

else

{

echo "answer=error";

}

?>

submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);

function sendMessage(e:MouseEvent):void{

var my_vars:URLVariables = new URLVariables();

my_vars.senderName = name_txt.text;

my_vars.senderEmail = email_txt.text;

my_vars.senderMsg = message_txt.text;

var my_url:URLRequest = new URLRequest("mail.php");

my_url.method = URLRequestMethod.POST;

my_url.data = my_vars;

var my_loader:URLLoader = new URLLoader();

my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;

my_loader.load(my_url);

name_txt.text = "";

email_txt.text = "";

message_txt.text = "Message Sent";

}

I do have my real email in there I just took it out for this post.

This topic has been closed for replies.
Correct answer kglad

I'm sorry I am really novice with ActionScript. What does that mean to

assign my loader's dataFormat property to 'variables'?


you already have that set:

my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;

so you shouldn't see that error message if you're testing the code you posted.

2 replies

Known Participant
December 4, 2014

Here is my code:

submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);

function sendMessage(e:MouseEvent):void{

var my_vars:URLVariables = new URLVariables();

my_vars.senderName = name_txt.text;

my_vars.senderEmail = email_txt.text;

my_vars.senderMsg = message_txt.text;

var my_url:URLRequest = new URLRequest("mail.php");

my_url.method = URLRequestMethod.POST;

my_url.data = my_vars;

var my_loader:URLLoader = new URLLoader();

my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;

my_loader.load(my_url);

name_txt.text = "";

email_txt.text = "";

message_txt.text = "Message Sent";

}

kglad
Community Expert
Community Expert
December 4, 2014

i'm not sure what you mean by posting that last message.

again,

copy and paste your actionscript into a new fla with those textfields and that button.

publish an html and swf and upload both to a server (that supports php).

copy that php to a text file, name it mail.php and upload to the same directory as your html and swf.

kglad
Community Expert
Community Expert
December 4, 2014

there's no mail.php found in Macintosh%20HD/Users/animationmanx/Desktop/

Known Participant
December 4, 2014

Ok thanks I fixed that but now it says:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.

  at Error$/throwError()

  at flash.net::URLVariables/decode()

  at flash.net::URLVariables$iinit()

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

kglad
Community Expert
Community Expert
December 4, 2014

assign your loader's dataFormat property to 'variables'.