开发者

SWF -> FBJS not working with FBJS-Bridge

开发者 https://www.devze.com 2022-12-28 08:37 出处:网络
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.

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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消