Why I can't call method on nativeApplication.applicationDescriptor in Javascript?
In my html file which is in Adobe AIR project, I write following code to get a reference to the application descriptor:
var appXML = air.NativeApplication.nativeApplication.applicationDescriptor;
The statement is executed successfully. I can see appXML is referenced to the runtime.XML object from debugger. And if I call alert(appXML), I could see the application descriptor content shown in the alert dialog.
But, if I try to call a method on appXML like appXML.namespace(), then error开发者_运维问答 will be thrown said that:
TypeError: Value does not allow function calls.
And so as every method I tried, all failed. But the same method call works well in Actionscript.
Anyone know why?
To read the application descriptor file with JavaScript, you can use the DOMParser.
var AppXmlParser = new DOMParser();
var AppXML = AppXmlParser.parseFromString(air.NativeApplication.nativeApplication.applicationDescriptor, "text/xml").getElementsByTagName('application')[0];
var AppName = AppXML.getElementsByTagName("filename")[0].firstChild.data;
var AppVersion = AppXML.getElementsByTagName("version")[0].firstChild.data;
精彩评论