My attempt to transfer a string from an HTML page (using JavaScript) to a SWF file (ActionScript 2) was not successful.
After some research on Google, I came across this page.
However, the example code (version 1) mentioned on the page did not work in Internet Explorer. The browser displayed an error message stating: "object doesn't support this property or method."
What could be causing this issue? I am looking for a solution that does not involve using SWFObject.
The ActionScript code is as follows:
//Code sourced from Evan Mullins @ circlecube.com
//View the complete post at http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/
import flash.external.*;
//Setting up Communication from JavaScript to ActionScript
var methodName:String = "sendTextFromHtml";
var instance:Object = null;
var method:Function = receiveTextFromHtml;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
//ActionScript to JavaScript
//ExternalInterface.call("receiveTextFromFlash", _root.theText.text);
function receiveTextFromHtml(t) {
_root.theText.text = t;
}
_root.button.onRelease = function() {
ExternalInterface.call("receiveTextFromFlash", _root.theText.text);
_root.theText.text = "";
}
The JavaScript code is as follows:
function receiveTextFromFlash(Txt) {
document.getElementById('htmlText').value = Txt;
}
and the JavaScript onclick code:
getElementById('flash').sendTextFromHtml(htmlText.value); document.getElementById('htmlText').value = ''
Thank you.