- Home /
This question was
closed Aug 23, 2014 at 07:29 AM by
tanoshimi for the following reason:
The question is answered, right answer was accepted
Question by
jkfran · Aug 23, 2014 at 12:03 AM ·
nullreferenceexception
Object reference not set to an instace of an object (JS)
I'm going crazy, where is the problem?
public class Lang
{
private var Strings : Hashtable;
function Lang (path : String, language : String) {
var data : TextAsset = Resources.Load(path);
var xml : XmlDocument = new XmlDocument();
xml.Load(data.text);
...
The error is on the last line.
Call code:
function OnEnable () {
LMan = new Lang("lang", Application.systemLanguage.ToString());
}
The file is on root directory.
If I change the Constructs to:
function Lang (path : String, language : String) {
var xml : XmlDocument = new XmlDocument();
xml.Load(path);
And the call code to:
LMan = new Lang("lang.xml", Application.systemLanguage.ToString());
Works! but not in Android!
Sorry for my bad english.
Edit -- Ok, now work! I change:
function Lang (path : String, language : String) { var data : TextAsset = Resources.Load.(path); var xml : XmlDocument = new XmlDocument(); xml.LoadXml(data.text);
and i add the XML file to the directory Resources.
Comment
Call code:
function OnEnable () {
L$$anonymous$$an = new Lang("lang", Application.systemLanguage.ToString());
}
The file is on root directory.
If I change the Constructs to:
function Lang (path : String, language : String) {
var xml : XmlDocument = new XmlDocument();
xml.Load(path);
And the call code to:
L$$anonymous$$an = new Lang("lang.xml", Application.systemLanguage.ToString());
Works! but not in Android!
Sorry for my bad english.