【发布时间】:2013-12-27 20:34:48
【问题描述】:
我使用 swfobject 加载了我的 swf。在 AS3 中,我打了一个电话,调用 FB.ui 来显示支付窗口。至此,一切正常。 支付完成后,FB.ui 会调用应该回调到 AS3 的回调。我得到了对 swf 对象的引用,但实际的方法调用失败,对象不支持属性或方法。
我一直在阅读所有关于此的帖子,但找不到任何帮助。在我看来,getElementById 没有返回正确的对象。
这只发生在 IE 中。 Chrome 和 FireFox 工作正常。
var attributes = {};
attributes.id = "game";
attributes.name = "game";
attributes.align = "middle";
swfobject.embedSWF(
"game.swf", "flashContent",
"800", "600",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
// JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
.....
FB.ui(obj, function(data) {
if(!data) {
alert("There was an error processing your payment. Please try again!");
return;
}
// alert('called back order');
// IMPORTANT: You should pass the data object back to your server to validate
// the contents, before fulfilling the order.
var gameVar = document.getElementById("game");
//alert(gameVar);
//console.log(Object.prototype.toString.call(gameVar));
//alert(gameVar.purchaseCallback);
gameVar.purchaseCallback(data);
//console.log("Payment verification complete");
});
//handle errors here
//alert('some error');
return false;
}
让这个更奇怪的是,如果我在页面中添加以下内容,点击链接就可以了。 功能测试() { var game = document.getElementById("game"); 警报(游戏.purchaseCallback); } 测试
【问题讨论】:
-
当我的谷歌搜索发现有人与我一直在努力解决完全相同的问题时,我非常兴奋!这个解决方案对我不起作用(可能是因为我必须使用 wmode: direct,并且支付对话框显示在 swf 后面),但我认为它引导我走上了通往解决方案的新道路。
-
如果其他人在尝试解决 Stage3D 游戏的这个问题时偶然发现这里,这篇文章为我提供了完整的工作解决方案:flassari.is/tag/fb-ui
-
@daniel-schaffer roguenet和jbassking提到的解决方案不适合你吗?
-
@akmozo 不,是的! - 事实上,我将奖励 jbassking 的答案,因为它帮助我解决了困扰我数月的应用程序的问题!不过,SO 不允许您在 24 小时内奖励赏金。
-
@DanielSchaffer 好的,伙计,我没有看到“一个或多个答案具有示范意义,值得额外赏金”。 ;)
标签: javascript actionscript-3 facebook-graph-api