This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Flash Site Design > January 2005 > Paypal: Buy Now Buttons





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Paypal: Buy Now Buttons
Freeky Bonjela

2005-01-11, 7:17 pm

I am trying to create a button in flash which when clicked allows the buyer to
purchase a bands CD, but has one cost for UK residents and another for
elsewhere. So far i have the button working so that it will charge one set fee
and i have coded the flash button as follows: on (release) {
getURL('www.oosterdok.com&cancel_return=http%3A//www.oosterdok.com&no_no
te=1?cy_code=GBP'
target='_blank'>https://www.paypal.com/xclick/busin...wnhouserecords.
com&undefined_quantity=1&item_name=Some+day+we+will+part+forever+%28EP%2
9&item_number=BHR00001&amount=4.00&page_style=PayPal&no_shipping
=2&return=http%3A//www.oosterdok.com&cancel_return=http%3A//www.oosterdo
k.com&no_note=1?cy_code=GBP'); } any ideas how to add a drop down so
that the user can choose UK or Rest of World which updates the price from ?4 to
?5 accordingly thanx

ultimateCF

2005-01-11, 11:15 pm

You would have to create an event handler that "listens" for when the combobox
is changed. There is a copy/paste example in the help files. It is approx in
this path. component dictionary > combobox > using the combobox in an
application > there is the example.

Just set a variable in the listener, that is read when the button is clicked.
You will have an if statement in your button code to handle the different rates.

You could do the same thing with radiobuttons, which might be more user
friendly/smaller since you only have 2 options.

Post back if you don't have success with the example.

Freeky Bonjela

2005-01-13, 7:17 pm

Cheers ulitmateCF.....I haven't managed to find the source of the path you
described, but i did a search on google and found this link..
http://livedocs.macromedia.com/flas...pl/common/html/
wwhelp.htm?context=Flash_MX_2004&file=00002142.html is this describing
what you are referring to? And I would add this event handler code to the code
i already had included (as listed in my previous post) for the button? Would
this sufficiently alter to the price when the buyer was taken to the paypal
page? Sorry this is my first attempt at this so have little experience. I did
go down another route using the web snap-in from web assist. I have pretty much
achieved the same thing that we are talking about above with a combobox that
you choose UK or Rest of World from and it updates the price accordingly.
However for some reason the currency will not shift from dollars within
paypal, and I want it to be in pounds. is it possible for me to send you the
fla file for you to look at? many thanx

ultimateCF

2005-01-13, 7:17 pm

Yes that is the exact code from the help files. This code does not get
attached to your button, but rather the timeline. This code will control the
setting of a variable. The button then reads that variable to set the correct
price. Here is how the code should work in your file.



//assigns the value of a variable to the label that was selected in a combobox
function change(evt){
_global.myPrice = evt.target.selectedItem.label;
trace(evt.target.selectedItem.label);
}
myComboBox.addEventListener("change", this);

//this gets attached to your button, just incorporate the variable into your
link to run your pricing logic. i think in paypal you have two different links
for the different prices

on(release){
if(myPrice == "Price A"){
//put link to paypal price a here
}else if (myPrice == "Price B"){
//put link to paypal price b here
}else{
//display an error, because they did not select anything
}

}


ps: I typed this out fast online, so double check for any goof ups.

Freeky Bonjela

2005-01-15, 12:17 pm

Cheers ulitmateCF.....I haven't managed to find the source of the path you
described, but i did a search on google and found this link..
http://livedocs.macromedia.com/flas...pl/common/html/
wwhelp.htm?context=Flash_MX_2004&file=00002142.html is this describing
what you are referring to? And I would add this event handler code to the code
i already had included (as listed in my previous post) for the button? Would
this sufficiently alter to the price when the buyer was taken to the paypal
page? Sorry this is my first attempt at this so have little experience. I did
go down another route using the web snap-in from web assist. I have pretty much
achieved the same thing that we are talking about above with a combobox that
you choose UK or Rest of World from and it updates the price accordingly.
However for some reason the currency will not shift from dollars within
paypal, and I want it to be in pounds. is it possible for me to send you the
fla file for you to look at? many thanx

Freeky Bonjela

2005-01-15, 7:18 pm

thanks, i think i am almost there. I have got the paypal button/movie to send
you to the paypal purchase screen, however if i change the location from uk to
rest of world it doesn't update the price when you are taken to paypal. I have
obviously missed something. My flash file is under 400kb, could i send this to
you so you could see t first hand? I'll list the code below just for reference.
In the timeline i have.. // Set the initial price for when the movie loads
setPrice(); function setPrice() { // Get the price (based on location)
var newPrice = location.getValue(); // Set visible price on page thePrice
= '?' + location.getValue(); } //assigns the value of a variable to the label
that was selected in a combobox function change(evt){ _global.newPrice =
evt.target.selectedItem.label; trace(evt.target.selectedItem.label); }
newPrice.addEventListener('change', this); For the button I have..
on(release){ if(newPrice =
'4'){getURL('https://www.paypal.com/xclick/business=info%40brownhouserecords.com
&undefined_quantity=1&item_name=Some+day+we+will+part+forever+%28EP%29&a
mp;item_number=BHR00001&amount=4.00&page_style=PayPal&no_shipping=2&
amp;return=http%3A//www.oosterdok.com&cancel_return=http%3A//www.oosterdok.c
om&no_note=1&currency_code=GBP'); }else if(newPrice =
'5'){getURL('https://www.paypal.com/xclick/business=info%40brownhouserecords.com
&undefined_quantity=1&item_name=Some+day+we+will+part+forever+%28EP%29&a
mp;item_number=BHR00001&amount=5.00&page_style=PayPal&no_shipping=2&
amp;return=http%3A//www.oosterdok.com&cancel_return=http%3A//www.oosterdok.c
om&no_note=1&currency_code=GBP'); } } the combobox is called
'location' and the dynamic text that displays the price has the variable
'thePrice'. thanks again...

ultimateCF

2005-01-18, 7:18 pm

Post it somewhere and I will dl it. In the meantime you can troubleshoot as
well. Put trace statements inside of your if statement so you know if either
logic path is being triggered. That will help you isolate what is broken and
aide you in fixing this and future movies.



if(myPrice == "4"){
trace("A is true");
}else if(myPrice == "5"){
trace("B is true");
}else{
trace("error could not evaluate if");
}

ultimateCF

2005-01-18, 7:18 pm

Post it somewhere and I will dl it. In the meantime you can troubleshoot as
well. Put trace statements inside of your if statement so you know if either
logic path is being triggered. That will help you isolate what is broken and
aide you in fixing this and future movies.



if(myPrice == "4"){
trace("A is true");
}else if(myPrice == "5"){
trace("B is true");
}else{
trace("error could not evaluate if");
}

Freeky Bonjela

2005-01-18, 11:20 pm

Cheers ulitmateCF.....I haven't managed to find the source of the path you
described, but i did a search on google and found this link..
http://livedocs.macromedia.com/flas...pl/common/html/
wwhelp.htm?context=Flash_MX_2004&file=00002142.html is this describing
what you are referring to? And I would add this event handler code to the code
i already had included (as listed in my previous post) for the button? Would
this sufficiently alter to the price when the buyer was taken to the paypal
page? Sorry this is my first attempt at this so have little experience. I did
go down another route using the web snap-in from web assist. I have pretty much
achieved the same thing that we are talking about above with a combobox that
you choose UK or Rest of World from and it updates the price accordingly.
However for some reason the currency will not shift from dollars within
paypal, and I want it to be in pounds. is it possible for me to send you the
fla file for you to look at? many thanx

Freeky Bonjela

2005-01-19, 7:20 pm

Hi, you can download my flash file from the site address of the website I am
creating www.oosterdok.com hope you have better luck than me. Let me know as
soon as you have downloaded it as i need to put the site back up - cheers

ultimateCF

2005-01-19, 11:18 pm

Got it, I will look at it tomorrow and post back.
Freeky Bonjela

2005-01-24, 7:18 pm

hiya,

you had any luck yet?
Freeky Bonjela

2005-01-25, 12:32 pm

fantastic......you're a star....i wasn't meaning to pressure you sorry....
thanx....
ultimateCF

2005-01-25, 12:32 pm

Ok, I looked at the .fla. The issue is that you are using old components with
code meant to work with the MX04 components. In one of your first posts, you
were using a livedoc url from Flash 04 and that is the code I provided. Do you
not have 04? If not then we have 2 options.

1-If this is an app you don't plan on editing, then you can download a trial
of Flash 04 and switch out the combobox for the new one.
2-I can point you in the right direction for the MX code, which based on your
example you seemed to have most of it already written.

Let me know.

Freeky Bonjela

2005-01-25, 11:17 pm

Ahhh i see. Well i only used the url for flash MX 2004 as it was the closest
thing i could find to what you were describing at the time. I must admit I
hadn't noticed it was a url helping flash MX 04 users only. whoops. If you
could i would rather correctly write the code for the version i have, just
plain old flash mx. so if you have the time option 2 please. thanx

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews