Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  80] [ 3]  / answers: 1 / hits: 18488  / 16 Years ago, tue, march 31, 2009, 12:00:00

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.


More From » apache-flex

 Answers
2

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.


[#99776] Tuesday, March 24, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mackenzihannal

Total Points: 548
Total Questions: 96
Total Answers: 96

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;