Flex 外部接口回调 [英] Flex ExternalInterface callback

查看:27
本文介绍了Flex 外部接口回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

弹性:

public function callFromJavaScript():String
{
       test.label='dfdsfsdf';
       return "1";
}
public function init():void {
       ExternalInterface.addCallback("sendToFlash", callFromJavaScript);
}

HTML

<object classid='clsid:x-x-x-x-x' height='200px' width='300px'>
        <param name="allowScriptAccess" value="always" />
        <param name='src' value='${swf}.swf'/>
        <embed  name='mySwf' id='qwe' src='${swf}.swf' height='200px' width='300px'/>
</object>

我知道有多种 (JavaScript) 方法,例如:document.getElementById('FlexAppId').setName(name);

I know there are multiple (JavaScript) methods like: document.getElementById('FlexAppId').setName(name);

然而:

  1. 我不知道哪个是跨​​浏览器兼容的(无法安装 IE 进行测试)
  2. 我尝试了多个但我无法让它们工作(在任何浏览器中),我可能使用了错误的 ID,我一直在试用 &错误几个小时,但我没有任何工作.(我听说本地文件系统上的 ExternalInterface.addCallback 有问题?我应该上传 swf 吗?< flex 代码是否正确& 问题 = JavaScript/html 方面?)

推荐答案

ExternalInterface 函数在浏览器和操作系统之间存在问题.一些建议是,

ExternalInterface functions are know to have issues across browsers and operating systems. Some of the recommendations are,

  1. 用户 swfobject 或任何其他标准库来嵌入您的 swf.(swfobject)
  2. 使用allowscriptaccess=always"
  3. 为嵌入标签提供正确的idname
  4. idname 属性应该始终相同.
  5. 如果您的 swf 文件来自与 html 页面不同的域,请使用 Security.AllowDomain('domain-of-html-page.com')
  1. User swfobject or any other standard library to embed your swf. (swfobject)
  2. Use 'allowscriptaccess=always'
  3. Give proper id and name to the embed tag
  4. id and name attribute should be always same.
  5. If your swf file is coming from a different domain than the html page, use Security.AllowDomain('domain-of-html-page.com')

这篇关于Flex 外部接口回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆