Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 Error

Explorer ,
Dec 03, 2014 Dec 03, 2014

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.

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 04, 2014 Dec 04, 2014

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.

Translate
Community Expert ,
Dec 03, 2014 Dec 03, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2014 Dec 03, 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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2014 Dec 04, 2014

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2014 Dec 04, 2014

I am still getting this message

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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

then you're not using the code you posted or your local computer doesn't support php.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2014 Dec 04, 2014

What should I do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

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.

test.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2014 Dec 04, 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";

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2014 Dec 04, 2014

It seemed to work like you said once I uploaded it to my website server. However, I haven't received the email.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

did you remember to change that email address?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 06, 2014 Dec 06, 2014

Thank you I just saw I didn't change it in the php file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2014 Dec 06, 2014

so, all's well?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 08, 2014 Dec 08, 2014

Well, I thought so but the email never showed up in my inbox. Here is exactly what I have in the actionscript. And I uploaded the php file too.

this.stop();

<?php

$to = "myemailHERE";

$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";

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2014 Dec 08, 2014

you need to change this line:

$to = "myemailHERE";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 08, 2014 Dec 08, 2014

I have the right email in that spot I just changed it for the purpose of this post. Is it right that I posted the php in the action script panel as well as uploading a separate file to my server?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2014 Dec 08, 2014

no php should be in your actionscript.  if it is, you should see compiler errors.

the php needs to be in a file named mail.php saved without text formatting (like ms windows would add).  ie, use a plain text editor like notepad or wordpad.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 09, 2014 Dec 09, 2014

I just got it to work completely. That must have been the last problem. That I made the php file using ms word. Thank you for  all the help, I really appreciate it!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2014 Dec 09, 2014
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines