send from javascript to actionscript IE problem

纵然是瞬间 提交于 2019-12-11 08:59:56

问题


I tried to send a string from an html page (with javascript) to a swf file (action script 2).

i searched in google, found this page.

but the example code (version 1, not 2, you can find it in the source file .zip) didn't work in IE (IE said: object doesn't support this property or method)

where is the problem? (i don't want to use SWFObject.)

the action script :::

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

and the onclick js code:::

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

Thank you.


回答1:


give this javascript code a try?

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

function addToResults(results) { getFlashMovie("flashdemo").addToResults(results); }


来源:https://stackoverflow.com/questions/6723074/send-from-javascript-to-actionscript-ie-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!