SWF-> FBJS 无法与 FBJS-Bridge 一起使用

发布于 2024-08-29 21:58:00 字数 949 浏览 5 评论 0原文

我试图从加载到应用程序选项卡中的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手心的海 2024-09-05 21:58:00

我花了一天时间解决这个问题。您必须声明任何 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文