32 Replies Latest reply on Oct 1, 2009 10:32 AM by iSleek

    E-mail Form (beginner..)

    iSleek

      What's up guys?

       

      After a few tries, I finally got my e-mail form to communicate with my PHP script and have that send an e-mail.

       

      First of all, let me explain how my form is composed:

       

      I have 2 elements:

       

      1) Movieclip "form" which includes my input text fields (ie: name, e-mail, comment).

      2) Send button.

       

      Here's the code for my send button:

       

      on (release) {

      if (name eq "" or mail eq "" or comment eq "") {

      stop ();

      } else {

      form.loadVariables("send.php", "POST");

      play();

      }

      }

       

      Again, the e-mail portion works just fine. What i'm trying to do with the "if/else" part is make sure that none of those things are left blank. If not, the user can just hit "send" and it would send a blank e-mail every time.

       

      As you can see, I'm not very experienced with Actionscript.

       

      Help?

       

      Thanks guys!

       

       

      iSleek

        • 1. Re: E-mail Form (beginner..)
          kglad Adobe Community Professional & MVP

          and what do you want to have happen (other than not send an email) if those fields are empty?

          • 2. Re: E-mail Form (beginner..)
            iSleek Level 1

            Hey Kglad, thanks for your interest in the topic.

             

            Well first I'd just like it to validate, maybe just do a stop(); for now, then when i see that it works, I can make it gotoAndPlay(frame); that I want - displaying an error message

             

            Does this make sense?

             

            Thanks!!

             

             

            iSleek

            • 3. Re: E-mail Form (beginner..)
              kglad Adobe Community Professional & MVP

              isn't that already happening?  when those fields are empty, no email is sent, correct?

               

              if email is sent when those fields look empty, they are not empty.  check if they are html-enabled or kerning is checked and make sure their variable name's are correct.

              • 4. Re: E-mail Form (beginner..)
                iSleek Level 1

                Hey, kerning is not enabled, and their variable name is correct.

                 

                How would I check to see if HTML is enabled?

                 

                Also, my assumption was that this is not working because of the actual code I typed, since "name" is inside of a movieclip called Form, I thought the right way to call that variable would be "form.name", even though on the code says just "name" (for example).. I tried "form.name" but that didn't work either.

                 

                I'm not sure if there's a "getVariables" or something like that so it can check the value, and THEN make sure it's not empty.. is that possible?

                 

                THanks!

                • 5. Re: E-mail Form (beginner..)
                  kglad Adobe Community Professional & MVP

                  when those fields are empty what do the following show:

                   


                   

                   

                  on (release) {

                  trace(name);

                  trace(mail);

                  trace(commnet);

                  if (name == "" or mail == "" or comment == "") {

                  stop ();

                  } else {

                  form.loadVariables("send.php", "POST");

                  play();

                  }

                  }

                   


                  • 6. Re: E-mail Form (beginner..)
                    iSleek Level 1

                    that's not working either..

                     

                    let's see..

                     

                    on (release) {

                    form.trace(name); \\ i'm not quite sure where these are tracing from.. and i'm also not sure how to make it trace those variable names from the movieclip "forms"..
                    form.trace(mail);
                    form.trace(commnet);

                     

                    if (name eq "" or mail eq "" or comment eq "") { \\ I tried with both "==" and "eq".. no go.

                    stop ();
                    }

                     

                    else {
                    form.loadVariables("send.php", "POST"); \\this is loading the variables from the movieclip called "form".. I guess the prefix "form." makes the PHP work
                    play();                                                     so smoothly. i wonder if this would have something to do with tracing the variable names above..
                    }
                    }

                     

                    i'm puzzled.. specially because I don't know the code but i'm also trying to logically understand it i guess..

                     

                    thanks for your help! i hope we can get this working

                     

                    iSleek

                    • 7. Re: E-mail Form (beginner..)
                      kglad Adobe Community Professional & MVP

                      what's the following show in the output panel:

                       


                       


                       

                       

                      on (release) {

                      trace(name+"::");

                      trace(mail+"::");

                      trace(comment+"::");

                      if (name == "" or mail == "" or comment == "") {

                      trace("in");

                      stop ();

                      } else {

                      trace("out")

                      form.loadVariables("send.php", "POST");

                      play();

                      }

                      }

                       


                      • 8. Re: E-mail Form (beginner..)
                        iSleek Level 1

                        hey, thank's so much for trying!

                         

                        I tested the code and it still doesn't validate..

                         

                        here's the website: http://www.isleekdesign.com/test.html

                         

                        go to the contact part and hit send.. you'll see what I mean..

                         

                        also, if you don't mind, could you explain the code to me? I just want to understand what's it supposed to do.

                         

                        thanks!!!

                        • 9. Re: E-mail Form (beginner..)
                          kglad Adobe Community Professional & MVP

                          i didn't ask if it's validating.  i asked what's in the output panel.

                          • 10. Re: E-mail Form (beginner..)
                            iSleek Level 1

                            oh.. sorry.. i'm not familiar with the terms..

                             

                            so when I do ctrl+enter, I get no errors.. how can i see what the output panel is displaying? the only thing I see is "list objects" or "list variables" at the "Debug" menu..

                             

                            thanks!

                            • 11. Re: E-mail Form (beginner..)
                              kglad Adobe Community Professional & MVP

                              attached to the frame that contains your button attach:

                               

                              trace("HI");

                               

                              // what do you see when you use ctrl-enter?

                              • 12. Re: E-mail Form (beginner..)
                                iSleek Level 1

                                here's what I see:

                                 

                                HI
                                undefined
                                undefined
                                undefined
                                out
                                Error opening URL 'file:///C|/Documents%20and%20Settings/Marcio%20Vieyra/Escritorio/iSleekDesign/iSleekDesi gn%20WebSite/%5FFLA/send.php'

                                 

                                The error is showing because the .php is in a different folder.. but when the file's on the server it works fine of course.

                                 

                                Here's the current code, I guess it's going "out" bypassing the validation for some reason..

                                 

                                on (release) {

                                 

                                trace(name);

                                trace(mail);

                                trace(comment);

                                 

                                if (name == "" or mail == "" or comment == "") {

                                trace("in");

                                stop ();

                                 

                                } else {

                                trace("out")

                                form.loadVariables("send.php", "POST");

                                play();

                                }

                                }

                                • 13. Re: E-mail Form (beginner..)
                                  kglad Adobe Community Professional & MVP

                                  so, name, mail and content are undefined.  you don't have textfields with those variable names and you need to fix that.

                                   

                                  if those variables are in a movieclip with instance name form, you would use:

                                   

                                  form.name, form.mail and form.content

                                   

                                  if you have no idea what you're doing you can attach:

                                   

                                  trace("submit "+this) where you have the current trace(name)

                                   

                                  and you can attach

                                   

                                  trace("tf "+name);

                                   

                                  to the timeline that contains your textfields and copy and paste the output panel results.  you can remove that trace("HI") function.

                                  • 14. Re: E-mail Form (beginner..)
                                    iSleek Level 1

                                    here's what I get:

                                     

                                    tf undefined
                                    submit _level0.instance110
                                    undefined
                                    undefined
                                    undefined
                                    out
                                    Error opening URL 'file:///C|/Documents%20and%20Settings/Marcio%20Vieyra/Escritorio/iSleekDesign/iSleekDesi gn%20WebSite/%5FFLA/send.php'

                                     

                                    Here's the code on the button..

                                     


                                    on (release) {
                                        trace("submit "+this);
                                        trace(name);
                                        trace(mail);
                                        trace(comment);
                                       
                                       
                                    if (name == "" or mail == "" or comment == "") {

                                     

                                    trace("in");

                                     

                                    stop ();

                                     

                                    } else {

                                     

                                    trace("out")

                                     

                                    form.loadVariables("send.php", "POST");

                                     

                                    play();

                                     

                                    }

                                    • 15. Re: E-mail Form (beginner..)
                                      kglad Adobe Community Professional & MVP

                                      the timeline where you "think" you have a variable name has no such variable.

                                       

                                      so, when in the flash program when you click on the textfield that you think is related to name what do you see in the properties panel?  does the textfield have an instance name (in the box below Input Text) or a variable name (in the box to the right of Var:)?

                                      • 16. Re: E-mail Form (beginner..)
                                        iSleek Level 1

                                        here, I've attached a screenshot of what I see..

                                         

                                        the text fields are inside my movieclip form, which is inside of another movie clip called tween 51, as you can see on the photo.

                                         

                                        so here's "tree"

                                         

                                        Screne 1

                                             - Movieclip Tween 51

                                                  - Movieclip Form

                                                       - Text fields: name, email, company, comment

                                                  - Send and scroll buttons

                                         

                                        Does this make sense?

                                         

                                        thanks!

                                        • 17. Re: E-mail Form (beginner..)
                                          kglad Adobe Community Professional & MVP

                                          on the timeline that contains body_txt attach:

                                           

                                          trace(body_txt);

                                           

                                          // and are there also name_txt and email_txt textfields?

                                          • 18. Re: E-mail Form (beginner..)
                                            iSleek Level 1

                                            no, the only thing is body_txt with th evariable name comment..

                                             

                                            i added what you suggested, and also name_txt and email_txt on that same timeline.

                                             

                                            here's what it displays:

                                             

                                            _level0.instance112.form.body_txt
                                            _level0.instance112.form.name_txt
                                            _level0.instance112.form.email_txt
                                            submit _level0.instance112
                                            undefined
                                            undefined
                                            undefined
                                            out
                                            Error opening URL 'file:///C|/Documents%20and%20Settings/Marcio%20Vieyra/Escritorio/iSleekDesign/iSleekDesi gn%20WebSite/%5FFLA/send.php'
                                            _level0.instance112.form.body_txt
                                            _level0.instance112.form.name_txt
                                            _level0.instance112.form.email_txt

                                             

                                            strange.. :/

                                            • 19. Re: E-mail Form (beginner..)
                                              kglad Adobe Community Professional & MVP

                                              now use:

                                               

                                               


                                               


                                               

                                               

                                              on (release) {

                                              if (form.name_txt.text == "" || form.email_txt.text == "" || form.body_txt.text == "") {

                                              // do whatever.  one of the textfields is empty

                                              } else {

                                              form.loadVariables("send.php", "POST");

                                              play();

                                              }

                                              }

                                               


                                              • 20. Re: E-mail Form (beginner..)
                                                iSleek Level 1

                                                that last one worked like a charm

                                                 

                                                thanks man, you were really helpfull this will definitely help me in the future as well

                                                 

                                                I also hope this helps someone else with this same problem.

                                                 

                                                cheers!

                                                • 21. Re: E-mail Form (beginner..)
                                                  kglad Adobe Community Professional & MVP

                                                  you're welcome.

                                                  • 22. Re: E-mail Form (beginner..)
                                                    iSleek Level 1

                                                    hey kglad! got a quick question you might be able to answer..

                                                     

                                                    I'm working on a different website now.. and it's written in AS2.0... the thing is that I have a Flash photo gallery in AS3.0.. and I'm trying to do a:

                                                     

                                                    on(release){

                                                         loadMovie ('gallery.swf', 1);

                                                    }

                                                     

                                                    The problem with this is that the  gallery loads but keeps on flickering, like trying to load infinitely.

                                                     

                                                    If i change the code for this:

                                                     

                                                    on(release){

                                                         loadMovieNum ('gallery.swf', 0);

                                                    }

                                                     

                                                    The gallery loads but my original page is gone, since it's obviously taking over the "0" level.

                                                     

                                                    Is there a way to make the AS3.0 gallery load within my AS2.0 homepage normally?

                                                     

                                                     

                                                     

                                                    Thanks!

                                                     

                                                     

                                                     

                                                    iSleek

                                                    • 23. Re: E-mail Form (beginner..)
                                                      kglad Adobe Community Professional & MVP

                                                      you can load an as3 swf into an as2 swf but none of the actionscript will work so you'll end up with an unsatisfactory result.

                                                       

                                                      the only workarounds are:

                                                       

                                                      1. use a main as3 swf that loads your as2 swf and also loads the gallery.swf

                                                       

                                                      or

                                                       

                                                      2.  load the as3 swf in a new browser window.

                                                      • 24. Re: E-mail Form (beginner..)
                                                        iSleek Level 1

                                                        thanks for your answer!

                                                         

                                                        I like the first option best, which is why I created a new .swf called "index".

                                                         

                                                        Here's the code in the first frame of "index.swf":

                                                         

                                                        stop();

                                                        var contenedor = new Loader();

                                                        contenedor.load(new URLRequest("home.swf"));

                                                        addChildAt(contenedor, 0);

                                                         

                                                        Here's the code within "home.swf" which would load "gallery1.swf" (but doesn't):

                                                         

                                                        on(release){

                                                        var contenedor2 = new Loader();

                                                        contenedor2.load(new URLRequest("gallery1.swf"));

                                                        addChildAt(contenedor2, 1);

                                                        }

                                                         

                                                        I also tried with:

                                                         

                                                        on(release){

                                                             loadMovie ('gallery1.swf', 1);

                                                        }

                                                         

                                                        But it does not load.. no error messages, nothing.. just click and nothing happens.

                                                         

                                                        Any ideas what I'm doing wrong?

                                                         

                                                        Thanks!

                                                         

                                                         

                                                        iSleek

                                                        • 25. Re: E-mail Form (beginner..)
                                                          kglad Adobe Community Professional & MVP

                                                          1. use a main as3 swf that loads your as2 swf and also loads the gallery.swf

                                                           

                                                          BOTH your as2 swf and gallery.swf must be loaded by the as3 index.swf

                                                          • 26. Re: E-mail Form (beginner..)
                                                            iSleek Level 1

                                                            Then I guess my question is:

                                                             

                                                            how can I make a button on the as2 (home.swf) load a movie by the index.swf? I still want home.swf to be visible when slideshow1.swf opens up.. is that possible? thanks!

                                                            • 27. Re: E-mail Form (beginner..)
                                                              kglad Adobe Community Professional & MVP

                                                              you can use localconnection to communicate between your as3 index.swf and your as2 swf.

                                                               

                                                              you as2 button will use localconnection to call a method in your index.swf and that method will load gallery.swf

                                                              • 28. Re: E-mail Form (beginner..)
                                                                iSleek Level 1

                                                                hey kglad, thanks for that!

                                                                 

                                                                i'm not sure how to write the code, this is what i've tried..

                                                                 

                                                                on(release){

                                                                gallery1 = new LocalConnection();

                                                                gallery1.load(new URLRequest('gallery1.swf'));

                                                                }

                                                                 

                                                                But obviously not working

                                                                 

                                                                Any ideas?

                                                                 

                                                                Thanks!

                                                                • 29. Re: E-mail Form (beginner..)
                                                                  kglad Adobe Community Professional & MVP

                                                                  you really shouldn't have code attached to objects.  so in the first frame that contains your button, assign your button an instance name (say loadGalleryBtn), use:

                                                                   

                                                                  var sendLC:LocalConnection=new LocalConnection();

                                                                   

                                                                  loadGalleryGtn.onRelease=function(){

                                                                  sendLC.send("as2TOas3connection", "loadF", "gallery.swf");

                                                                  }

                                                                   

                                                                  // and in the first frame of your as3 index.swf:

                                                                   

                                                                  var receiveLC:LocalConnection=new LocalConnection();

                                                                  receiveLC.client=this

                                                                  receiveLC.connect("as2TOas3connection");

                                                                   

                                                                  var ldr:Loader=new Loader();

                                                                   

                                                                  function loadF(s:String){

                                                                  ldr.load(new URLRequest(s));

                                                                  }

                                                                  • 30. Re: E-mail Form (beginner..)
                                                                    iSleek Level 1

                                                                    ok so I named my button what you suggested, then applied the code you suggested to the first frame where the button appears on my timeline.

                                                                     

                                                                    Here's the error I get:

                                                                     

                                                                    The class or interface "Loader" could not be loaded. var ldr:Loader=new Loader();

                                                                     

                                                                    :S

                                                                    • 31. Re: E-mail Form (beginner..)
                                                                      kglad Adobe Community Professional & MVP

                                                                      then your index.swf is not being published for as3.

                                                                      • 32. Re: E-mail Form (beginner..)
                                                                        iSleek Level 1

                                                                        meh.. I gave up on that and started creating an AS2 gallery.

                                                                         

                                                                         

                                                                        so.. when you're on the main page and click on "photo gallery", it loads an external swf called "gallery.swf" so you can view the photos.

                                                                         

                                                                        the problem with this is that when gallery.swf is loaded, the buttons on the main page (which is underneath gallery) are still clickable! so if i were to click on the "photo gallery" button, it would load the gallery.swf all over again -_-

                                                                         

                                                                        is there a way to work around this? meaning, when the gallery.swf is loaded, disable all buttons on main.swf? and then when gallery.swf is unloaded, activate the buttons again?

                                                                         

                                                                        thanks!