I want to say hello to all and thanks for letting me a part of this great forum. I am having some problems with my flash site (www.alliancedirect.net) and I am using Adobe Flash CS4 now with my site with ActionScript 1.0.

I have a form already made on the site (under contact us) but whatever I do....I can't make it work! I use GoDaddy and their gdform.psp is what they provide but they don't give the code in flash. I downloaded some different flash mail scripts and programs but I don't know how to incorporate it within my own site and I don't know what to do! I just want the information to be submitted to me via email and the other forms I will make away from the flash portion if it is too complicated.

Please let me know what specific information you may need from me and how you can hopefully help me as soon as possible as I need this website completely up and running. Again, I appreciatre the help and look forward to being a part of your community!

-sasss

    The basics of getting Flash to talk to PHP is to upgrade your actionscript version. Don't use anything lower than 2. AS 2 makes it easier to talk with external scripts. Using AS 2 you can use the function sendAndLoadVars() to send data and get a response back.

    Using AS 3 you have to use a couple classes, namely URLLoader and URLVariables, to send data to an external script.

    The basics of it are this (I'm going to use AS 2 since I just got done backporting an AS 3 form to AS 2):

    • Create the form elements

    • Assign names to the elements (using the property inspector)

    • Assign actionscript to the submit button to call a submit() function we'll define

    • Assign actionscript to the reset button to call a reset() function we'll define

    The basics of the actionscript are this:

    function reset():Void {
        full_name.text = '';
        email.text = '';
        phone.text = '';
        message.text = '';
    }
    
    function submit():Void {
        // Do some basic validation
        if(full_name.text == '' || email.text == '' || phone.text == '' || message.text == '') {
            // Display an error message
        }
        else
        {
            var result:LoadVars = new LoadVars();
            result.onLoad = function(success:Boolean) {
                if(success) {
                    // Display success message
                }
                else {
                    // Display error message
                }
            };
    
        var send:LoadVars = new LoadVars();
        // Assign data to the POST
        send.email = email.text;
        send.fullName = full_name.text;
        send.phone = phone.text;
        send.message = message.text;
    
        // Send the request via POST to a url
        send.sendAndLoad('http://www.domain.tld/myscript.php', result, 'POST');
    }
    }

    Now, with those once you send the data your php script can access the data in the POST array like:

    <?php
    
    $_POST['email']; // The user supplied email address
    $_POST['fullName']; // The user supplied full name
    $_POST['phone']; // The user supplied phone number
    $_POST['message']; // The user supplied message

    Now, if you want to allow "talking" between PHP and Flash, you need to structure your response from PHP to flash just like the query string of a $_GET request in the url. So to send data back, you'd structure it like so:

    &someVar=some string&someOtherVar=some more data you want sent back&anotherVar=some more information!

    Then in flash, you can reference the response object (in our code above it's "result"). To do that, you would do it like so:

            var result:LoadVars = new LoadVars();
            result.onLoad = function(success:Boolean) {
                if(success) {
                    // Display success message
                    trace(result.someVar);
                    trace(result.someOtherVar);
                    trace(result.anotherVar);
                }
                else {
                    // Display error message
                }
            };

    Hope that helps you start somewhere....

      The basics of getting Flash to talk to PHP is to upgrade your actionscript version. Don't use anything lower than 2. AS 2 makes it easier to talk with external scripts. Using AS 2 you can use the function sendAndLoadVars() to send data and get a response back.

      Using AS 3 you have to use a couple classes, namely URLLoader and URLVariables, to send data to an external script.

      The basics of it are this (I'm going to use AS 2 since I just got done backporting an AS 3 form to AS 2):

      • Create the form elements

      • Assign names to the elements (using the property inspector)

      • Assign actionscript to the submit button to call a submit() function we'll define

      • Assign actionscript to the reset button to call a reset() function we'll define

      The basics of the actionscript are this:

      function reset():Void {
          full_name.text = '';
          email.text = '';
          phone.text = '';
          message.text = '';
      }
      
      function submit():Void {
          // Do some basic validation
          if(full_name.text == '' || email.text == '' || phone.text == '' || message.text == '') {
              // Display an error message
          }
          else
          {
              var result:LoadVars = new LoadVars();
              result.onLoad = function(success:Boolean) {
                  if(success) {
                      // Display success message
                  }
                  else {
                      // Display error message
                  }
              };
      
          var send:LoadVars = new LoadVars();
          // Assign data to the POST
          send.email = email.text;
          send.fullName = full_name.text;
          send.phone = phone.text;
          send.message = message.text;
      
          // Send the request via POST to a url
          send.sendAndLoad('http://www.domain.tld/myscript.php', result, 'POST');
      }
      }

      Now, with those once you send the data your php script can access the data in the POST array like:

      <?php
      
      $_POST['email']; // The user supplied email address
      $_POST['fullName']; // The user supplied full name
      $_POST['phone']; // The user supplied phone number
      $_POST['message']; // The user supplied message

      Now, if you want to allow "talking" between PHP and Flash, you need to structure your response from PHP to flash just like the query string of a $_GET request in the url. So to send data back, you'd structure it like so:

      &someVar=some string&someOtherVar=some more data you want sent back&anotherVar=some more information!

      Then in flash, you can reference the response object (in our code above it's "result"). To do that, you would do it like so:

              var result:LoadVars = new LoadVars();
              result.onLoad = function(success:Boolean) {
                  if(success) {
                      // Display success message
                      trace(result.someVar);
                      trace(result.someOtherVar);
                      trace(result.anotherVar);
                  }
                  else {
                      // Display error message
                  }
              };

      Hope that helps you start somewhere....

        Write a Reply...