Paypal hosted buttons

Hi,

This code is posted in several places saying it works with paypal. For some reason, for me, it does not work - I get to paypal’s homepage instead. However, the same code (sort of) works if I just use a straight html page. I don’t get it.

AS3


addcart.addEventListener(MouseEvent.CLICK, addItem);

function addItem (event:MouseEvent):void
{
var url:String = 'https://www.paypal.com/cgi-bin/webscr';
var request:URLRequest = new URLRequest(url);
var paypal:URLVariables = new URLVariables();
paypal.cmd='_s-xclick';
paypal.hosted_button_id='5529701';
paypal.instanceName='addcart';

request.data = paypal;
request.method = URLRequestMethod.POST;
navigateToURL(request, '_blank');
}

HTML


<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="5529701">
<input type="image" src="http://www.kiwemail.com/images/button.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>