2010-02-09 39 views
0

我使用FBML为FB应用程序Flash调用FBJS

我有一个Flash和闪存设想调用页面上的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. 

回答

1

你有没有尝试改变:

connection.send(connectionName, "callmenow", "callmenow", pArray); 

connection.send(connectionName, "callFBJS", "callmenow", pArray); 
+0

现在的工作。谢谢。 – Murvinlai 2010-02-11 07:37:35