View Full Version : Telling Flash email sent/failed

01-24-2008, 02:50 PM

I have the following AS2 script in an FLA file (MX 2004) to send a message from my Flash site to my inbox:

on (release) {

//Import variables to be sent

name = _root.name_txt.text
email = _root.email_txt.text
business = _root.business_txt.text
country = _root.country_txt.text
message = _root.message_txt.text


//When Flash receives an answer from the server...

this.onData = function() {

//Move to the next frame

if(this.output=='sent') {

//If successful...

_root.errTitle = 'Thank You.';
_root.errType = "Your message has been succesfully sent.";


//and if not successful...

_root.errTitle = "Error!";
_root.errType = "An error has occurred. Please try again later.";


I hope everything looks right there, but my asp file contains no script to indicate to Flash that the email has been sent. In other words, where I have the following

//When Flash receives an answer from the server...

In the Action Script above, Flash waits for ever to receive an answer. This is probably why my email 'hangs' at the moment after having clicked the contact form's 'submit' button.

What I would like to ask is this:

How do I script a response in ASP which my fla file will understand? Is there a 'standard' response? Or should I use the line from the script above, namely:


And what about if the email 'fails'.

Many thanks for any advice.


01-24-2008, 05:52 PM
Response.Write "output=sent"

Response.Write "output=error"

Your variables in ASP should print something simliar to that, then flash can retrieve them like above.

01-25-2008, 02:23 PM
Hello sstalder

Thank you for your message.

I suspected my Flash fla file needed to reflect what ASP was asking.

I have form with the following AS (2):

var dataSender:LoadVars = new LoadVars();

var dataReceiver:LoadVars = new LoadVars();

//assign properties to LoadVars object created previously

dataSender.name = name_txt.text;
dataSender.email = email_txt.text;


//callback function - handling what comes back

dataReceiver.onLoad = function() {
if (this.response == "invalid") {
alert_txt.text = "Sorry, but your email address appears invalid"

} else if (this.response == "passed") {
//now send data to script

dataSender.sendAndLoad("flash.asp", dataReceiver, "POST");
} else {

//if fields are incomplete

alert_txt.text = "Please complete all fields";

This suggests I would need to have something like:

Response.Write "&output=invalid"
Response.Write "&output=passed"

in my ASP form. So I now have this:

On Error resume next

If Err.Number <> 0 then
Response.Write "&output=invalid"
Response.Write "&output=passed"
End if

I get no server error messages and data is sent from my Flash form to my inbox. The data is also stored in my database. But the email hangs endlessly. Not for a few minutes (!), but I have to click out of it to stop it from telling me it is still trying to process my request to sent the form data.

What do you think might be causing this?

Many thanks for your time.