I have the following callback:

ExternalInterface.addCallback("wasCalledFromJS", callFromJavaScript);

which is implemented like this:

    public function callFromJavaScript(dir:String):void {
    try {
        scriptName = dir.toString();
    } catch (e:*) {
        Alert.show(e.toString());
    }
}

However, when I try to call it from the JS console, in the following way ( with the method defined in How to call flash actionscript callback method from javascript? ):

>>> thisMovie("Flex4TextArea1").wasCalledFromJS("1")

"Error in Actionscript. Use a try/catch block to find error."

It appears as if the code if not even reaching my try/catch block. Can you spot what I'm doing wrong?

EDIT: After adding Security.allowDomain("*"); it works. Why am I required to do this, even when testing on localhost? It is the same domain, is it not?

有帮助吗?

解决方案

Error was caused because domain priviledges were not set.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top