开发者

Flash JavaScript (Ajax) doesn't work in IE?

I made a Flash application that add's conte开发者_如何学JAVAnt to a page using JavaScript(Ajax). But strangely enough it doesn't work in IE(7 nor 8). It works fine in Chrome and FireFox.

The JavaScript function is (probably) not the problem, because when I insert javascript:functionName(id); in my browser it works.

In my Flash I use the JavaScript on a button with the following code:

getURL("javascript:functionName(id);");

I suppose that, that's a good way to use it?

But strangely enough nothing works in Flash, not even if I replace the code with alert('hello my friend');(maybe he's not my friend?).

Could someone help me out and tell me what may be causing the problem?

Thanks in advance!


You should be using AS ExternalInterface to communicate with JS, have a look on this: http://www.nelsond8.com/?p=515#more (here I'm using swfobject built in method swfobject.getObjectById, if you are not using swfObject replace this line with document.getElementById)

If you are using AS2, you could do something like this:

<script type="text/javascript">
function myFunction(id)
{
alert('hello my friend');       
return 'hello my friend';

}
</script>

AS2:

import flash.external.*;

btn.onPress = function() 
    {
        var jsReply:String = String(ExternalInterface.call("myFunction", "01"));

        getURL("jsReply");

        trace(jsReply);
    }

And here is the externalInterface reference page for AS2: http://flash-reference.icod.de/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜