开发者

Why I can't call method on nativeApplication.applicationDescriptor in Javascript?

开发者 https://www.devze.com 2022-12-15 10:54 出处:网络
In my html file which is in Adobe AIR project, I write following code to get a reference to the application descriptor:

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;
0

精彩评论

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