Sunday, October 2, 2011

AS2: Paypal Donate Button

Source File Available Here: http://adf.ly/30e2V
Welcome to Tutorial #8! In this tutorial I will show you how to add a Paypal option in Flash for purchasing items.

Let's start by opening up a new Flash AS2 document:












Now lets create a button that says "Paypal" on it. Convert it to a button movieclip and name it "paypal_btn".













Also, make sure you give the button an instance name of "myPurchaseButton". If you don't give it that instance name, your button will be non-functional.













Now let's open up the actions of the button by clicking on it and hitting F9 on your keyboard or right clicking it and selecting "actions". Type this:


myPurchaseButton.onRelease = function() {
formData = new LoadVars();
formData.cmd = "_xclick";
formData.business = "my-email-example@domain.com";
formData.item_name = "Donation";
formData.amount = "$10.00";
formData.send("https://www.paypal.com/cgi-bin/webscr", formData, "POST");
};


The code is pretty much self explanatory. Just change the email, item_name, and amount to your preferences and you're done! Once you click the button, it should bring you to the purchase page in Paypal, prompting you of your pre-purchase.

Thank you for viewing this tutorial! Be sure to become a member to receive notifications of all new weekly tutorials on my blog!

Source File Available Here: http://adf.ly/30e2V

No comments:

Post a Comment