8 Replies Latest reply on May 28, 2010 1:18 PM by kglad

    Simple Flash Form

    el pescado Level 1

      So, I have given up on the PHP forms as they always seem to be a headache (for me anyways).


      I have used simple AS3 forms on other projects to enter in text fields and when the send button is hit, it gathers the text and the email client launches.  My client needs a simple form.  Name, Event, Phone # and free form message area.

       

      I used the below code.  All the trace statements work however the Phone # and Event are left out of the message.  The form has 4 input text fields with the correct instance names.  The email pops up.

       

      I have also had issue where the swf works fine but once I upload it with the HTML file, it doesn't work.

       

      Any suggestions would be great.

       

      Thanks.

       


      CODE:

       

      send_btn.addEventListener(MouseEvent.CLICK, sendData);

      function sendData(evtObj:MouseEvent):void{

      trace (name_text.text);

      trace (event_text.text);

      trace (phone_text.text);

      trace (message_text.text);

      var theEmail:URLRequest = new URLRequest("mailto:myemail@yahoo.com?from="+

      event_text.text+phone_text.text+"&subject=Sell My Tickets&body="+message_text.text+"   from:"+name_text.text);

      navigateToURL(theEmail, "_self");

      }

        • 1. Re: Simple Flash Form
          kglad Adobe Community Professional & MVP

          from should be an email address.  add even and phone to your body variable.

          • 2. Re: Simple Flash Form
            el pescado Level 1

            Perfect Klad, it worked.  Wasn't getting that.......I like these kind of forms though.

             

            This code worked but is there a way to space out each text entry to a new line?  It all comes bunched on one line in the email.


            Thanks.

             

            CORRECT CODE:

             

            send_btn.addEventListener(MouseEvent.CLICK, sendData);

            function sendData(evtObj:MouseEvent):void{

            trace (name_text.text);

            trace (event_text.text);

            trace (phone_text.text);

            trace (message_text.text);

            var theEmail:URLRequest = new URLRequest("mailto:myemail@yahoo.com?from="+"&subject=Sell My Tickets&body="+message_text.text+"   from:"+name_text.text+

            "   event:"+event_text.text+"   phone#:"+phone_text.text);

            navigateToURL(theEmail, "_self");

            }

            • 3. Re: Simple Flash Form
              kglad Adobe Community Professional & MVP

              use the new line character "\n":

               


              CORRECT CODE:

               

               

              send_btn.addEventListener(MouseEvent.CLICK, sendData);

              function sendData(evtObj:MouseEvent):void{

              trace (name_text.text);

              trace (event_text.text);

              trace (phone_text.text);

              trace (message_text.text);

              var theEmail:URLRequest = new URLRequest("mailto:myemail@yahoo.com?from="+"&subject=Sell My Tickets&body="+message_text.text+"\nfrom:"+name_text.text+

              "\nevent:"+event_text.text+"\nphone#:"+phone_text.text);

              navigateToURL(theEmail, "_self");

              }

              • 4. Re: Simple Flash Form
                el pescado Level 1

                That didn't seem to do it.......

                 

                I mean so that the email looks like:

                 

                 

                 

                Message:  Blah blah blah

                 

                Name:  Bob Smith

                 

                Event:  San Francisco Giants

                 

                Phone:  777-777-7777

                • 5. Re: Simple Flash Form
                  el pescado Level 1

                  Hey Kglad,


                  One more thing that wasn't answered (and I can start a new string/post).....


                  The email populates corrects when I run the swf.  However, when I publish and open up the HTML, hit send on the form.......nothing populates.

                   

                  Really strange because I used this on another site and it worked fine.


                  Thanks

                  • 6. Re: Simple Flash Form
                    kglad Adobe Community Professional & MVP

                    use %0A instead of \n

                    • 7. Re: Simple Flash Form
                      el pescado Level 1

                      Kglad,

                       

                      You are on fire today.  That worked great.  I read that n\ should work too, not sure why.

                       

                      Any reason this isn't working when I put it on my server?  Works fine when I play the swf.  Weird.

                       

                      Thanks again.

                      • 8. Re: Simple Flash Form
                        kglad Adobe Community Professional & MVP

                        i don't know why \n fails.  but it's easy enough to use %0A instead.