14 Replies Latest reply on Apr 22, 2007 8:24 PM by MotionMaker

    Flash Form Fields to Php variables

    Kyng_Lewie
      I have created a flash form which a user will fill out, when they release a flash button I have called the loadVariables into POST command. I have a php processing page that picks up the variable and emails them to a certain location. All of the currently works. However flash seems to be sending the font type, size etc along with the variable.

      Example: Mail sent by: <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Bitstream Vera Serif" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">Form Name Test</FONT></P></TEXTFORMAT>

      Anyone have any ideas how I might get rid of the text formating code?
        • 1. Re: Flash Form Fields to Php variables
          MotionMaker Level 1
          If your TextField is my_txt
          my_lv.varToPHP = my_txt.text;
          • 2. Re: Flash Form Fields to Php variables
            Kyng_Lewie Level 1
            Okay, so I have to redefine the variables to only text in actionscript before I ask flash to loadVars into my php stuff. How would that look like exactly? Lets say my flash variable name was 'Message' for my input text box. I would

            on release {
            message (being the php named variable) = message.text;


            - loadVars here after I have defined all variables to text and proceed right? -

            }

            Sorry about the simplicity of the question, doing a self taught crash course in Actionscript..
            • 3. Re: Flash Form Fields to Php variables
              MotionMaker Level 1
              The example at LoadVars.sendAndLoad is the template to do this.

              send_lv.varName1InPHP = _________________;
              send_lv.varName2InPHP = _________________;
              send_lv.varName3InPHP = _________________;

              Since these are LoadVars dynamic object members, Flash automatically types them to the expression on the right.

              Then LoadVars object will convert everything to text as that is what is sent over Internet.


              Your original question had to do with a Flash TextField object. To get just the text out of it without formatting you use the
              TextField.text property.
              • 4. Flash Form Fields to Php variables
                Kyng_Lewie Level 1
                Hey Motion, Sorry to bother again.. <-- Dumb Newbie.

                I want to give you some of my code snippets for clarity. I admit I should have in the first place but I am a little bashfull.
                I have inserted my Flash code, just for reference I will add my php code as well.

                The code was working prior to the addition of me trying to define the input text fields to be sent only with text and not the formatting. I tried what I thought you were showing me and then tried a few more things with the syntax.

                Note on my input text fields - I selected all the text fields and defined them as a movie clip named Form.

                Flash gives me the sucessfully sent message, but I don't quite believe it. The php processing doesn't run.

                If you want more graphic detail the form I am trying to use is live right now @ [Removed].

                Now, when I get this working I start fooling with form field checking. Whoohoo!
                • 5. Re: Flash Form Fields to Php variables
                  MotionMaker Level 1
                  There are two forms of loadVariables
                  MovieClip.loadVariables
                  clipInstanceName.loadVariables(url:String, [method:String]) : Void
                  and
                  loadVariables global function
                  loadVariables(url:String, target:Object, [method:String]) : Void

                  It looks like in your code you are using a hybrid of the two. The one you are using does not have a target object.

                  With loadVariables is can be confusing to know what scope of variables it is reading and what scope it is updating and why most folks have moved on to LoadVars.sendAndLoad.

                  Looking at your code
                  _root.Form.loadVariables("Bidsubmission.php", this, "POST");

                  I think it is saying update the matching variables in the _root.Form scope that are received from the PHP. Not sure what it is saying about what scope to send variables since the target (this) argument does not exist for this version of loadVariables.

                  I will post a LoadVars example in a few minutes using your code.
                  • 6. Re: Flash Form Fields to Php variables
                    MotionMaker Level 1
                    See if this code will work.
                    • 7. Re: Flash Form Fields to Php variables
                      Kyng_Lewie Level 1
                      I didn't have any luck. I put the code in the first frame of my Form movie clip.

                      I had to encase the first part of the code you gave me in a onClipEvent (load) { (code) } as flash was sputtering about it.

                      Then I put the button code in my send button. Still isn't happy. =/

                      Maybe I am putting elements in the wrong place.

                      Is it possible that my MovieClip and Send button should not be in the same frame? Should my Button be Inside the movie clip? Argh.

                      • 8. Re: Flash Form Fields to Php variables
                        MotionMaker Level 1
                        "flash was sputtering about it. " What does that mean?
                        Not all the code goes in the first frame. The comments in the code I posted tell you where to place it. Part goes into the first frame and I need to assume the first frame is not replayed over and over.

                        The on code goes into a Button symbol instance. The assumption is that the button is on the scene 1 timeline and not embedded inside another object.

                        If this does not go well then I suggest you create a simple Flash Movie with one button on one frame. Place the frame code on that frame and the on code for the button. Then in the on code assign the send_lv values constants for example send_lv.Fname = "Joe"; send_lv.Fname = "Smith"; and debug that.

                        Once you get that working then you can get into the layer approach you have.


                        You can do all of this in the Form MovieClip if you want but I would suggest that is not the problem. The problem is your learning curve and knowing how this works and how to debug client server applications. So stay focused on that goal and then you can work back to how you want to design the UI.
                        • 9. Re: Flash Form Fields to Php variables
                          Kyng_Lewie Level 1
                          Thanks for the help Motion - the sputtering I was refereing to were errors like: Code must be containted in an onclipevent. Easy enough to fix.

                          Your right, my learning curve sucks. This is the first time I have ever used flash and Php -at all-. I will work on it some more and let you know the results.
                          • 10. Re: Flash Form Fields to Php variables
                            Kyng_Lewie Level 1
                            Well, maybe I should take a step back and just look at a few things.

                            I now have my Content (aside from a background picture) in one frame.

                            I have Form - My movie clip. No Actionscript written in it at all.
                            The first keyframe of the movie has the top part of the code you gave me. I added stop(); to that first frame as it was advanceing to my second keyframe which is the receipt message.

                            Send_lv.Fname is a variable name that is supposed to be taking the value of my input text fields and loading them (assuming into an array) without the html formatting code.

                            I understand all of your code, what I am questioning are the relative paths for the variable asignment (will use your debugging strat). And the fact that I have variable names asigned for me text fields (Fname etc.. you understand) but I have no instance names - Is that an issue?

                            Again, I am sorry for taking more of your time. I very much appreciate the help - as such the background for this project is actually my senior project for my bachelors degree in college. The school is quite small, few here have worked with actionscript.
                            • 11. Re: Flash Form Fields to Php variables
                              MotionMaker Level 1
                              1. Debug the server script with the simplest way possible.
                              a. Can the script be called in the web browser window and what do you see? Assuming PHP has the display_errors flag set to send errors back on you can see if the script has got errors. Careful sometimes the errors may be due to the PHP script not getting needed data.
                              b. Send the correct data. That is often a plain HTML form.

                              2. If that seems to work then consider a Flash movie that sends static values to your PHP script.

                              I attached one:
                              • 12. Re: Flash Form Fields to Php variables
                                Kyng_Lewie Level 1
                                Okay motion, good news.

                                I made a simple html form and debugged a few php things from there. I still get undifined variable errors in php, however all wanted data still seems to be intact.

                                I ran flash again, where as it did not advance to the next frame with a return recipt, it did send your static form data.
                                Output:
                                ------------------------------------------------------------------------------
                                Bid Submissions
                                Reply-To: Joe <joe@smith.org

                                X-Mailer: PHP/4.3.10
                                X-Priority: 1


                                Get it done

                                ---------------------------
                                Mail sent by: Joe <joe@smith.org>
                                Name of Person Submitting (first):Joe (Last):Smith
                                Address Line 1:1 Main Street Adress Line 2:
                                Phone Number:999-999-1111 Zip Code:099229
                                Fax:999-999-9999
                                Project Title:Get it done Project Location:Home
                                Email Address of Submitter:joe@smith.org
                                Additional Comments or Messages:Blah blah
                                --------------------------------------------------------------------------------
                                • 13. Re: Flash Form Fields to Php variables
                                  Kyng_Lewie Level 1
                                  Motion - Good news.

                                  I broke apart "Form" and just left them as input text fields in the first frame.

                                  Then I removed the "Var" field names for each of the input text boxes and placed them in the Instance name field.

                                  Code works, formated nicely. The only problem is that anyone can enter anything, even submit a blank form. For now this is acceptable though!

                                  - Thanks alot for your help, much appreciated.
                                  • 14. Re: Flash Form Fields to Php variables
                                    MotionMaker Level 1
                                    Great! Good to have a working base to then add back those features you lost.