ExternalInterface.call()没有得到返回值 [英] ExternalInterface.call() not getting return value

查看:288
本文介绍了ExternalInterface.call()没有得到返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaScript函数,该函数返回一个div的innerHTML。我试图调用从ActionScript这个函数和存储返回值。我知道的JavaScript函数被调用,因为没有显示的返回数据,返回到动作脚本,但是,是空的数据警报。我不知道是什么原因造成这一点。这里是什么,我试图做一个code例如:

I have a Javascript function that returns the innerHTML of a div. I am attempting to call this function from Actionscript and store the return value. I know that the Javascript function is being called because there is an alert that displays the return data, The data that is returned to Actionscript, however, is null. I am not sure what is causing this. Here is a code example of what I am attempting to do:

Javascript:
function JSFunc () {
     var x = document.getElementById("myDiv");
     alert(x.innerHTML);
     return x.innerHTML;
}

Actionscript:
import flash.external.*;
if (ExternalInterface.available) {
     var retData:Object = ExternalInterface.call("JSFunc");
     if(retData != null) {
          textField.text = retData.toString();
     } else {
          textField.text = "Returned Null";
     }
} else {
     textField.text = "External Interface not available";
}

就像我前面说的,警报显示了该div的内容,但在文本框的文本总是返回NULL,这意味着ExternalInterface的是可用的。我要补充一点,我只能在IE7和IE8测试。怎样做任何意见将是多少AP preciated。

Like I said earlier, the alert shows up with the contents of the div but the text in the textfield is always "Returned Null", meaning that the ExternalInterface is available. I should add that I can only test this in IE7 and IE8. Any advice on what to do would be much appreciated.

推荐答案

我一直有这个问题的来源必须做,我用嵌入Flash影片对象标记。我用接下来这个例子标签 http://www.w3schools.com/flash/ flash_inhtml.asp ,我把它改为匹配这个例子: HTTP ://kb.adobe.com/selfservice/viewContent.do外部ID = tn_4150 ,然后我确信,我加号的对象和一切工作?

The source of the problem that I have been having has to do the object tag that I was using to embed the flash movie. I was using a tag that followed this example http://www.w3schools.com/flash/flash_inhtml.asp, I changed it to match this example: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_4150 and then I made sure that I added id to the object and everything worked.

这篇关于ExternalInterface.call()没有得到返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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