I added an extra argument to a ExternalInterface called that was 
already working. This argument is an object with one of its 
properties being XML. 
 After I added the object, the JS function  was not being called 
anymore. After a little debugging, it looks like you cannot send XML 
or a nested property in an object with XML. I got this error message 
after calling ExternalInterface.call

Error #1090: XML parser failure: element is malformed.

I will probably end up copying the object and parse the XML to a 
string before passing to JS. But I am curious to hear if someone else 
has run into this issue and if they have any solution to it.

This is simplified example that shows the issue:

package {
                
        import flash.display.Sprite;
        import flash.external.ExternalInterface;

        public class ExternalInterfaceTest extends Sprite
        {
                public function ExternalInterfaceTest()
                {
                        callExternalFunction();
                }
                
                public function callExternalFunction():void{
                
                        var oFormat:Object = new Object();
                        var myXML:XML = 
<rootNode><childTest>test1</childTest></rootNode>;
                        oFormat.name="test";
                        oFormat.localXML = new XML( 
localXML.toXMLString());
                        ExternalInterface.marshallExceptions=true;
                        try{
                                ExternalInterface.call
("myJSFunction",oFormat);
                                } catch (e:Error){
                                        trace(e.message);
                               //Error #1090: XML parser failure: 
element is malformed.
                        }
                        

                }

        }
}


and the JS function:

<script language="JavaScript" type="text/javascript">
function myJSFunction(str) {
    alert(str);
}
</script>

Thanks


Reply via email to