Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExternalInterface.call() not getting return value

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";
}

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.

like image 482
Adam Richardson Avatar asked Mar 31 '09 14:03

Adam Richardson


1 Answers

This is a working sample based on the code you provided. You can right click it to view the source. I suspect the problem lies in the HTML for 'myDiv' or when you are making the actionscript call.

like image 110
Osman Avatar answered Oct 07 '22 09:10

Osman