16 Replies Latest reply on Jan 21, 2007 2:21 PM by

    onClipEvent Issue

    firewall72 Level 1
      Hi,

      I have a form that is used to submit an email (PHP script). The form and email work well, but I'm unable to proceed to the next frame using the "onClipEvent(data) action script. Bascially, I would like a Thank you or Email confirmation page to follow the submit. Currently, the email works but the page doesn't refresh. See code below.

      Applied to form (Movie Clip):
      onClipEvent(data){
      // show welcome screen
      _root.nextFrame();
      }

      Applied to Submit button:
      on (release) {
      // send variables in form movieclip (the textfields)
      // to email PHP page which will send the mail
      form.loadVariables("email.php", "POST");
      }

      I tried using the code below to see if the movie was receiving data from PHP, but it didn't work.

      onClipEvent (data) {
      trace(data);
      _root.nextFrame();
      }

      Anyone have any ideas? Please be patient, I am new to Flash. Thank you!

      John
        • 1. Re: onClipEvent Issue
          kglad Adobe Community Professional & MVP
          is the php script sending something back?
          • 2. Re: onClipEvent Issue
            firewall72 Level 1
            No. It appears to run a quick animation in the parent or root movie, displays the same text entered in the form and sends the form to the PHP script. The email is sent and looks OK. I just want send it to the next frame and inform the user that the email was sent. I also tried using a label on the frame and modifying the Action Script. Any ideas? Thanks.
            • 3. Re: onClipEvent Issue
              kglad Adobe Community Professional & MVP
              if no data is returned, that onClipEvent(data) handler isn't going to execute and there's really no reason to have it execute.

              the usual point to have a data handler is to delay execution of code that needs some return variable/value. because you don't need anything returned, just execute _root.nextFrame() after your submit button is pressed.
              • 4. Re: onClipEvent Issue
                firewall72 Level 1
                OK, thanks. I have removed the handler and applied the script below to the button. However, the email is not sent. I do see the "thanks" from below with the back button funtional. Is there a way to delay the sctipt between submitting the form for the PHP script and advancing to the "thanks" frame? I don't think the form is making it to the email script. Thanks!

                on (release) {
                // send variables in form movieclip (the textfields)
                // to email PHP page which will send the mail
                form.loadVariables("email.php", "POST");
                _parent.pages.gotoAndStop("thanks");

                }
                • 5. Re: onClipEvent Issue
                  kglad Adobe Community Professional & MVP
                  there is a way to delay the execution of code using setInterval() or setTimeout(), but that's not going to solve your problem.

                  are you sure email.php has no errors? have you tested it by hard-coding the data that's needed? if so, are you sure those data are also in your form movieclip?
                  • 6. Re: onClipEvent Issue
                    firewall72 Level 1
                    Not sure. The email script does work, but I'm not sure if it has an error further into the sctip. I will check the script line by line. Once that is done, what else should I try?

                    Thank you.
                    • 7. Re: onClipEvent Issue
                      kglad Adobe Community Professional & MVP
                      if you hard code the data used by your php script (ie, the email's subject, body, from and to are coded in your php script and do not parse data sent from flash) and it works you can then look at the parsing of your data from flash to your php script.

                      you can use the trace() function in flash to check if all the variables needed in form are defined and you can post your php code here that parses the variables sent from flash.
                      • 8. Re: onClipEvent Issue
                        firewall72 Level 1
                        Hi,

                        I'm not sure I follow. As you can tell, I'm a newbie when it comes to flash. Do you see any issues with my script below. I have a form with "name", "email" and "message" fields and it does send the email.

                        <?php
                        $sendTo = "firewall72@gmail.com";
                        $subject = "Shore Thing Designs Contact Form";
                        $headers = "From: " . $_POST["name"];
                        $headers .= "<" . $_POST["email"] . ">\r\n";
                        $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
                        $headers .= "Return-Path: " . $_POST["email"];
                        $message = $_POST["message"];
                        mail($sendTo, $subject, $message, $headers);
                        ?>
                        • 9. Re: onClipEvent Issue
                          onClipEvent(data){
                          // show welcome screen
                          _root.nextFrame();
                          }
                          I have change the way of doing forms and skipped onClipEvent(data){ to verify if the script was
                          executed right.
                          Here´s a mofication of a kirupa form with it´s php script (I ´ve echo out a string in the end of the php-script.
                          You´´ll see if you take a look at the attaching .zip-file)

                          If you try to build your form with loadVars and a php-script that echo a string (you can echo out a variable
                          if you want that too) from the server, when it´s executed right, the form always works.
                          (I hope someone else has the opposite experience ;-) )


                          In the .fla file:
                          You only need to look at frame 100-104.´
                          The form is in a mc called "mc_contact_rider"

                          Please, dont forget the right path on the send button.
                          • 10. Re: onClipEvent Issue
                            firewall72 Level 1
                            Hello,

                            I get an unexpected file format on the .fla file. Any chance you can try to upload another copy to your server?

                            Thanks.
                            • 11. Re: onClipEvent Issue
                              Ok :-)
                              • 12. Re: onClipEvent Issue
                                Now you can test again
                                :-)
                                • 13. Re: onClipEvent Issue
                                  firewall72 Level 1
                                  HI.

                                  The movie contains 1 layer and 1 frame. I don't see anything in frames 100-104. Please advise.

                                  Thanks.
                                  • 14. Re: onClipEvent Issue
                                    You hve to scroll to the right in the main timeline.
                                    If you dont, you cant see the movieclip which is only 70 x 70 px.
                                    Look down to the right , don´t you see a little blue rectangular mc?
                                    • 15. Re: onClipEvent Issue
                                      firewall72 Level 1
                                      OK, so you are recommending that I change this:

                                      on (release) {
                                      // send variables in form movieclip (the textfields)
                                      // to email PHP page which will send the mail
                                      form.loadVariables("email.php", "POST");
                                      _parent.pages.gotoAndStop("thanks");

                                      }

                                      To this?

                                      on(press){
                                      _global.closeForm = true;
                                      _global.contactLoaded = false;
                                      }
                                      on (release) {
                                      form.loadVariables("email.php", "POST");
                                      this._parent.gotoAndPlay("thanks");
                                      }
                                      • 16. Re: onClipEvent Issue
                                        Just use frame 90 to 103 in m y example - the rest of the frames is prudced for a mask tween in my portfolio.
                                        Try tu use only the part frame 100 - 103 that handle the form and not the animation.
                                        I´m gonna upload som new example-
                                        Forget the variables _global on frame 100 and just write:
                                        stop();
                                        System.useCodepage = true;
                                        on frame 101:
                                        if ("skickat == ja") {
                                        gotoAndStop("klart");
                                        }

                                        if ("skickat == ja"){
                                        gotoAndStop("klart"); //here´s a important statement!. If this statment works, the php script was executed.
                                        //You must echo out ("sending back") the same string value at the end of the php script email.php

                                        }

                                        on frame 102:
                                        gotoAndPlay(_currentframe-1);

                                        on frame 103:
                                        stop();

                                        on frame 103:
                                        display a thank you screen
                                        and make the label.
                                        finsih (or you can use the swedish verison called "klart")

                                        on the send button - try this:
                                        on (release) {
                                        // send variables in form movieclip (the textfields)
                                        // to email PHP page which will send the mai
                                        form.loadVariables(" http://yoursite.com/femail.php", "POST");//form is the instance of the mc
                                        play();
                                        }


                                        if you dont copie my form with animation and all that - just cange the above frame to 1,2,3 instead