Flex的ExternalInterface的回调 [英] Flex ExternalInterface callback
本文介绍了Flex的ExternalInterface的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
软硬度:
公共职能callFromJavaScript():字符串
{
test.label ='dfdsfsdf';
返回1;
}
公共职能的init():无效{
ExternalInterface.addCallback(sendToFlash,callFromJavaScript);
}
HTML
<对象的classid =CLSID:XXXXX高度=200px的宽度=300px的'>
< PARAM NAME =allowScriptAccess的值=总是/>
<参数名称='src'中值='$ {}瑞士法郎的.swf/>
<嵌入的名字='mySwf'ID ='QWE'SRC ='$ {}瑞士法郎的.swf高度=200px的宽度=300px的'/>
&所述; /对象>
我知道有多重(JavaScript)的方法,如: 的document.getElementById('FlexAppId')的setName(名);
不过:</ P>
- 我不知道至极One的crossbrowser兼容(不能安装IE来测试)
- 我已经试过多次,但我不能让他们的工作(在任何浏览器),即时通讯可能使用了错误的ID,我一直都试用和放大器;示数了几个小时,但我没有什么工作。 (我听说有一个本地文件系统ExternalInterface.addCallback有问题?我应该上传瑞士法郎&LT;是柔性code右放大器;问题=的JavaScript / HTML端)
解决方案
ExternalInterface的
函数知道有没有跨浏览器和操作系统的问题。有些建议是, P>
- 用户
的SWFObject
或任何其它标准库中嵌入
您的SWF。 ( SWFObject的) - 使用的allowScriptAccess =总是
- 给予适当的
ID
和名称
于embed -
ID
和名称
属性应该是始终一致的。 - 如果您的SWF文件是从不同的域的HTML页面来了,使用
的Security.allowDomain(domain-of-html-page.com')
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>
I know there are multiple (javascript) methods like: document.getElementById('FlexAppId').setName(name);
However:
- I have no clue wich one are crossbrowser compatible (cant install IE to test out)
- I have tried multiple but i cant get them to work(in any browser), im probably using the wrong id, ive been trial & erroring for a couple of hours but i don't have anything working. (i heard there was a problem with ExternalInterface.addCallback on a local file system?, should i upload the swf? < is the flex code right& problem = javascript/html side?)
解决方案
ExternalInterface
functions are know to have issues across browsers and operating systems. Some of the recommendations are,
- User
swfobject
or any other standard library toembed
your swf. (swfobject) - Use 'allowscriptaccess=always'
- Give proper
id
andname
to the embed tag id
andname
attribute should be always same.- If your swf file is coming from a different domain than the html page, use
Security.AllowDomain('domain-of-html-page.com')
这篇关于Flex的ExternalInterface的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文