3 Replies Latest reply on Jan 20, 2007 4:12 AM by Peter Lorent

    LoadVars.onLoad returning failure..

    Marek_FlashUser
      Hello,

      I made a small app in flash that sends an e-mail by calling a simple mailing script in php. I used LoadVars to store the separate variables and then a call to sendAndLoad() to call the mailing script. It works. I get the e-mails just like i expected to, but for some reason, after a short delay the onLoad event handler for the LoadVars object constantly returns success = false after the call to sendAndLoad(). I've tried it on mozilla, IE, and Opera with the same result on all of them. I'm happy it works but I'd still like this fake error taken care of, so I can know when there is a real one. Any advice or suggestions are appreciated. Here is my code:
        • 1. Re: LoadVars.onLoad returning failure..
          Peter Lorent Level 2
          You are not returning anything to Flash from the PHP file.
          The PHP should do something like:
          // send email message
          $OK = mail($to, $subject, $message);
          // let Flash know what the result was
          if ($OK) {
          echo 'sent=OK';
          } else {
          echo 'sent=FAIL';
          }
          and in flash
          function ResultLoaded() {
          if (this.sent == "OK") {
          error_txt.text = "success";
          } else {
          error_txt.text = "failure;
          }
          }

          • 2. LoadVars.onLoad returning failure..
            Marek_FlashUser Level 1
            Thanks for the response Luigil.

            The onLoad function has the following parameter:
            success:Boolean - A Boolean value that indicates whether the load operation ended in success (true) or failure (false).
            So I tried at least echoing the direct result of the mail as in...

            echo "success = $success"

            leaving the flash as was and it worked. I guess it just needed something to be echoed back in order to claim set success to be true.
            • 3. Re: LoadVars.onLoad returning failure..
              Peter Lorent Level 2
              >>it just needed something to be echoed back
              True, but Flash doesn't know now if the mail was send successfully.
              You can't return a Boolean type from PHP because that datatype isn't recognized as a Boolean by Flash. It expects a String value and can only read a String value.