从javascript发送到actionscript IE问题

时间:2011-07-17 09:52:48

标签: javascript flash actionscript

我尝试从html页面(使用javascript)向swf文件发送字符串(动作脚本2)。

我在谷歌搜索,发现this page

但示例代码(版本1,而不是2,你可以在源文件.zip中找到它)在IE中不起作用(IE说:对象不支持这个属性或方法)

问题在哪里? (我不想使用SWFObject。)

动作脚本:::

//From Evan Mullins @ circlecube.com
//View post at http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/



import flash.external.*;

//Set up Javascript to Actioscript
var methodName:String = "sendTextFromHtml";
var instance:Object = null;
var method:Function = recieveTextFromHtml;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);

//Actionscript to Javascript
//ExternalInterface.call("recieveTextFromFlash", _root.theText.text);

function recieveTextFromHtml(t) {
    _root.theText.text = t;
}

_root.button.onRelease = function() {
    ExternalInterface.call("recieveTextFromFlash", _root.theText.text);
    _root.theText.text = "";
}

JS :::

function recieveTextFromFlash(Txt) {
    document.getElementById('htmlText').value = Txt;
}

和onclick js代码:::

getElementById('flash').sendTextFromHtml(htmlText.value); document.getElementById('htmlText').value = ''

谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个javascript代码吗?

function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName]; 
}  

function addToResults(results) { getFlashMovie("flashdemo").addToResults(results); }
相关问题