Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2008, 01:50 PM   PM User | #1
SteveH
Regular Coder

 
Join Date: Nov 2005
Posts: 615
Thanks: 91
Thanked 1 Time in 1 Post
SteveH is an unknown quantity at this point
Telling Flash email sent/failed

Hello

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

loadVariables("flash.asp",this,"POST");

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

this.onData = function() {

//Move to the next frame

_root.nextFrame();
if(this.output=='sent') {

//If successful...

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

}
else
{

//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:

if(this.output=='sent')

And what about if the email 'fails'.

Many thanks for any advice.

Steve
SteveH is offline   Reply With Quote
Old 01-24-2008, 04:52 PM   PM User | #2
sstalder
New to the CF scene

 
Join Date: Jan 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sstalder is an unknown quantity at this point
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.
sstalder is offline   Reply With Quote
Old 01-25-2008, 01:23 PM   PM User | #3
SteveH
Regular Coder

 
Join Date: Nov 2005
Posts: 615
Thanks: 91
Thanked 1 Time in 1 Post
SteveH is an unknown quantity at this point
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();

mainTL.play();
//assign properties to LoadVars object created previously

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

etc

//callback function - handling what comes back

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

} else if (this.response == "passed") {
mainTL.gotoAndStop(4);
}
}
//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.End
else
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.

Steve
SteveH is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:51 AM.


Advertisement
Log in to turn off these ads.