通过navigateURL传递变量以打开iFrame as3

时间:2014-08-10 19:37:01

标签: actionscript-3 iframe paypal navigateurl

通过使用NavigateURL,我可以轻松地通过Flash将变量传递给paypal,这没有问题,可以包含所需的所有数据。

var req:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
var reqVars:URLVariables = new URLVariables();
reqVars.cmd = "_xclick-subscriptions";
reqVars.business = "BUSINESS CODE";
reqVars.lc = "GR";
reqVars.item_name = "Product Name";
reqVars.item_number = "Product Number 0001";
reqVars.no_note = "1";
reqVars.no_shipping = "2";
reqVars.src = "1";
reqVars.a3 = "15.00";
reqVars.p3 = "1";
reqVars.t3 = "Y";
reqVars.currency_code = "EUR";

//and so on
req.data = reqVars;
req.method = URLRequestMethod.POST;
navigateToURL(req);

通过使用如下所示的callIframe,我可以轻松地从Flash打开iFrame。

calliFrame("http://www.webAddress.com/" +"?iframe=true&width=800&height=550", "Page Title", "Page Description");

function calliFrame(url:String, title:String, desc:String):void{
    if (ExternalInterface.available) {
        trace("calling prettyPhoto");
        try {
            ExternalInterface.call('$.prettyPhoto.open', url, title, desc);
        } catch (event:Error) {
            trace("Error occurred!");
        }
    } else {
        trace("External Interface unavailable");
    }
}

是否可以通过calliFrame方法传递navigateURL变量?我尝试了各种变体,但没有转移数据或显示页面。

我希望下面的示例可以使用,但只能获得空白页面或iFrame中显示的数据列表:

calliFrame("https://www.paypal.com/cgi-bin/webscr" +reqVars +"?iframe=true&width=800&height=550", "Page Title", "Page Description");

任何帮助都会非常感谢,提前谢谢。

1 个答案:

答案 0 :(得分:0)

第二个参数是窗口名称,所以你要做的就是传递你的iframe名称。

public function navigateToURL(request:URLRequest, window:String = null):void

docs:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html#navigateToURL()