我将 FBML 用于 FB 应用程序
我有一个闪光灯,闪光灯假设在页面上调用一个javascript。我阅读了很多网站试图弄清楚但仍然有问题。
这是带有 javascript 的网页:
<fb:fbjs_bridge/>
<div id="swfContainer"></div>
<script>
// the javascript to call and change the text of ztest001
function callmenow(a) {
var obj = document.getElementById("ztest001");
obj.setTextValue("Calling");
}
// generating the SWF
var swf = document.createElement('fb:swf');
swf.setId('my_swf_id');
swf.setWidth('630');
swf.setHeight('520');
swf.setSWFSrc('http://hollywood-life.madscience-games.com/ztest/test1.swf');
document.getElementById('swfContainer').appendChild(swf);
</script>
<div onclick="callmenow('a')">call me now</div>
<div id="ztest001"> YOo </div>
这里是 Flash 代码。(一帧。代码在帧上。带有文本框“myvar1”)
var connection:LocalConnection = new LocalConnection();
var connectionName:String = LoaderInfo(this.root.loaderInfo).parameters.fb_local_connection;
connection.allowDomain("apps.facebook.com", "apps.*.facebook.com");
function callFBJS():void{
myvar1.text = "START"; // debugging purpose
if (connectionName) {
myvar1.text = "Connection now"; // debugging purpose
var pArray = ['bs'];
connection.send(connectionName, "callmenow", "callmenow", pArray);
myvar1.text = "SENT";
}
}
callFBJS();
好吧,当我测试时,闪光灯会加载。该代码遍历所有内容并在 Flash 文本框中显示“SENT”。但是,它似乎并没有调用 javascript 并更改 HTML 页面中的文本。
我做错了什么吗?我尝试了 ExternalInteface.call 方法,但这也不起作用。
另外,当我在 FireFox 中运行它时,不会弹出错误。但是,当我在 IE 中运行它时,我得到了这个:
VerifyError: Error #1033: Cpool entry 36 is wrong type.
ReferenceError: Error #1065: Variable FBJS is not defined.