Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    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

  • #2
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •