I've searched the forums and all over the web and have not found an answer. I don't know why I get this error. It's extremely simple at the moment, starting the app. It was working when I had all the functions not in an object. Any help would be greately appreciated.
TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/removeEventListener()
$(document).ready(function() {
MyApp.init();
});
var MyApp = {
prefsFile: '',
prefsXML: '',
stream: '',
init: function() {
window.nativeWindow.addEventListener(air.Event.CLOSING, this.windowClosingHandler);
this.prefsFile = air.File.applicationStorageDirectory;
this.prefsFile = this.prefsFile.resolvePath("preferences.xml");
this.readXML();
},
readXML: function() {
this.stream = new air.FileStream();
if (this.prefsFile.exists) {
this.stream.open(this.prefsFile, air.FileMode.READ);
this.processXMLData();
} else {
this.saveData();
}
},
processXMLData: function() {
this.prefsXML = this.stream.readUTFBytes(this.stream.bytesAvailable);
this.stream.close();
var domParser = new DOMParser();
this.prefsXML = domParser.parseFromString(this.prefsXML, "text/xml");
var windowState = this.prefsXML.getElementsByTagName("windowState")[0];
window.moveTo(windowState.getAttribute("x"), windowState.getAttribute("y"));
},
saveData: function() {
this.createXMLData();
this.writeXMLData();
},
createXMLData: function() {
var cr = air.File.lineEnding;
this.prefsXML = "<?xml version='1.0' encoding='utf-8'?>" + cr
+ "<preferences>" + cr
+ " <windowState" + cr
+ " x = '" + window.screenLeft.toString() + "'" + cr
+ " y = '" + window.screenTop.toString() + "'" + "/>" + cr
+ " <saveDate>" + new Date().toString() + "</saveDate>" + cr
+ "</preferences>";
},
writeXMLData: function() {
this.stream = new air.FileStream();
this.stream.open(this.prefsFile, air.FileMode.WRITE);
this.stream.writeUTFBytes(this.prefsXML);
this.stream.close();
},
windowClosingHandler: function(e) {
e.preventDefault();
window.nativeWindow.removeEventListener(air.Event.CLOSING, this.windowClosingHandler);
this.saveData();
air.NativeApplication.nativeApplication.exit();
}
};