9 Replies Latest reply on Apr 15, 2007 3:14 PM by Newsgroup_User

    PayPal Donation button in Flash?

    rsinclair
      I'd like to add a button in Flash to link to a PayPal Donation function. How do I use the HTML code provided by PayPal (meant to be applied to a .GIF or. JPG) to a standard Button instance in Flash?

      Thanks.


        • 1. Re: PayPal Donation button in Flash?
          Level 7
          rsinclair,

          > How do I use the HTML code provided by PayPal (meant
          > to be applied to a .GIF or. JPG) to a standard Button
          > instance in Flash?

          Not so hard, which is nice. :)

          > <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
          > <input type="hidden" name="cmd" value="_xclick">
          > <input type="hidden" name="business" value="myemail@mywebsite.com">

          These "hidden" input fields are variables, so in Flash, you'll
          instantiate the LoadVars class and set them as properties of that instance
          ...

          var toPayPal:LoadVars = new LoadVars();
          toPayPal.cmd = "_xclick";
          toPayPal.business = "myemail@mywebsite.com";
          // etc.

          (I have no idea what _xclick means, by the way, but I'm just following the
          original code -- you'll have to test this, of course.)

          When it's time to submit, you'll invoke the LoadVars.send() method on
          your LoadVars instance, supplying the address given by PayPal:

          toPayPal.send(" http://www.paypal.com/someForm.asp", "_self", "POST");

          ... making sure to specify POST or GET as required by PayPal. All in all,
          it's the exact same concept, just wrangled into the LoadVars class
          implementation.

          Fire up the ActionScript 2.0 Language Reference and search "LoadVars
          class" for full details and additional code samples.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. PayPal Donation button in Flash?
            rsinclair Level 1
            Thanks, David. This is a little beyond my skill level/expertise, so I'm not able to troubleshoot effectively, even after reviewing the Help files.

            I've transcribed all of the variables into LoadVars as you described, and assumed I should place the code (attached below) in the first frame of my movie so the variables would be stored.

            I then placed this code on the instance of my button:

            on(release) {
            toPayPal.send("https://www.paypal.com/cgi-bin/webscr", "_self", "POST");
            }

            When I Publish, Flash reports an error in Line 1:

            **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 1: Expected a field name after '.' operator.
            toPayPal.

            Any idea what I'm doing wrong?

            Thanks!
            • 3. Re: PayPal Donation button in Flash?
              kglad Adobe Community Professional & MVP
              check your publish settings. they must be for flash 6 or better.
              • 4. Re: PayPal Donation button in Flash?
                rsinclair Level 1
                Publish setting is currently on Flash 8.
                • 5. Re: PayPal Donation button in Flash?
                  rsinclair Level 1
                  Looks like I had some extraneous code causing the error, whoops!

                  But... it still doesn't appear to work. The only web address in PayPal's original HTML code just leads to their homepage, so the button doesn't appear to be picking up the necessary variables indicating that it should lead to a Donation page.
                  • 6. Re: PayPal Donation button in Flash?
                    Level 7
                    rsinclair,

                    > Publish setting is currently on Flash 8.

                    The Flash Player version number -- as long as it's six or higher --
                    isn't as important, in this case, as the version of ActionScript. Because
                    of the post-colon suffix (e.g. :LoadVars) in my sample, you'll need to
                    publish to ActionScript 2.0. If that's still not it, reply again and we'll
                    troubleshoot through it.


                    David Stiller
                    Adobe Community Expert
                    Dev blog, http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: PayPal Donation button in Flash?
                      Level 7
                      rsinclair,

                      > Looks like I had some extraneous code causing the error, whoops!
                      >
                      > But... it still doesn't appear to work. The only web address in PayPal's
                      > original HTML code just leads to their homepage, so the button doesn't
                      > appear
                      > to be picking up the necessary variables indicating that it should lead to
                      > a
                      > Donation page.
                      >
                      >


                      • 8. Re: PayPal Donation button in Flash?
                        Level 7
                        rsinclair,

                        > Looks like I had some extraneous code causing the
                        > error, whoops!

                        Ahh, good to hear. :)

                        > But... it still doesn't appear to work [... ] the button
                        > doesn't appear to be picking up the necessary
                        > variables indicating that it should lead to a Donation
                        > page.

                        If you need to "pick up" variable -- do you mean receive a reply from
                        PayPal? -- you may want to use the LoadVars.sendAndReceive() method instead.
                        If that's not what you mean, it may just be an issue of scope, depending on
                        how you've set up your button.

                        To troubleshoot, replace your current on() code with this ...

                        on(release) {
                        trace(toPayPal);
                        // toPayPal.send("https://www.paypal.com/cgi-bin/webscr", "_self",
                        "POST");
                        }

                        .. which comments out the send mechanism and simply traces the toPayPal
                        object (your LoadVars instance) to the Output panel. If you see
                        "undefined," you'll know the button can't "see" this object.


                        David Stiller
                        Adobe Community Expert
                        Dev blog, http://www.quip.net/blog/
                        "Luck is the residue of good design."


                        • 9. Re: PayPal Donation button in Flash?
                          rsinclair Level 1
                          Aha! I was testing the button locally from within the Flash Player, but when I went through a web browser, it seems to work!

                          Thanks for your help, guys!