SWF-> FBJS 无法与 FBJS-Bridge 一起使用
我试图从加载到应用程序选项卡中的 SWF 调用 JS 函数。作为画布 FBML,代码可以正常工作,但在应用程序选项卡中则无法工作。
AS3代码:
protected function button1_clickHandler(event:MouseEvent):void
{
callFBJS(["insideFlex"])
}
protected function callFBJS(text:Array):void
{
var connection:LocalConnection = new LocalConnection();
var connectionName:String = loaderInfo.parameters.fb_local_connection;
if (connectionName)
{
logLbl.text = "Connection Name: " + connectionName;
connection.send(connectionName,"callFBJS","doSomething",text);
logLbl.text = logLbl.text + "\n" + "Method invoked";
}
}
JS代码:
<fb:fbjs-bridge/>
<fb:swf swfsrc="<SWF File>" imgsrc="http://www.easyhealth.org.uk/cmsimages/adobe_flash_1470_1470.jpg" height="655" width="760"/>
<script>
function doSomething(a)
{
console.log(a);
}
</script>
I'm trying to call a JS function from an SWF which is loaded inside an application tab. As a canvas FBML, the code is working correctly but in case of application tab it's not working.
AS3 Code:
protected function button1_clickHandler(event:MouseEvent):void
{
callFBJS(["insideFlex"])
}
protected function callFBJS(text:Array):void
{
var connection:LocalConnection = new LocalConnection();
var connectionName:String = loaderInfo.parameters.fb_local_connection;
if (connectionName)
{
logLbl.text = "Connection Name: " + connectionName;
connection.send(connectionName,"callFBJS","doSomething",text);
logLbl.text = logLbl.text + "\n" + "Method invoked";
}
}
JS Code:
<fb:fbjs-bridge/>
<fb:swf swfsrc="<SWF File>" imgsrc="http://www.easyhealth.org.uk/cmsimages/adobe_flash_1470_1470.jpg" height="655" width="760"/>
<script>
function doSomething(a)
{
console.log(a);
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了一天时间解决这个问题。您必须声明任何 FBJS 函数并通过单击 HTML 链接来调用它。单击后,基于 FBJS-bridge 的调用将起作用。我不明白如何或为什么,但这为我解决了问题。
I spent a day solving this issue. You have to declare any FBJS function and call it by clicking on an HTML link. After you click, the FBJS-bridge-based calls will work. I don't understand how or why, but this solved the problem for me.