したがって、fileList 配列の最初のファイルをロードするときに正しく呼び出される関数 fileLoaded では、this.loadAnother() を呼び出そうとしますが、Firefox は次のように主張します。
TypeError: this.loadAnother is not a function
関数ではないと主張するのはなぜですか?loadProjectSource() から正しく呼び出されていますが、次のファイルをロードしようとすると、関数ではありません。また、「これ」をデバッグすると奇妙な結果が得られるため、これが原因であると思われます。私は Javascript の専門家ではありませんが、この動作を見たことがありません。クラスの作成と関係がありますか? もしそうなら、loadProjectSource() からの最初の呼び出しが機能するのはなぜですか?
var ScriptLoader = Class.extend({ // Want to add functionality to this to allow PHP or inline loading...perhaps later
init: function () {
this.totalEngineToLoad = 0;
this.totalEntitiesToLoad = 0;
this.totalScenesToLoad = 0;
this.totalLoaded = 0;
this.entitiesToLoad = [0, 0, 0];
this.fileList = ['./js/engine/Entity.js', './js/engine/Scene.js'];
this.preload;
},
loadProjectSource: function (directory) {
if(this.preload != null) {
this.preload.close();
}
this.preload = new createjs.LoadQueue();
this.preload.addEventListener("fileload", this.fileLoaded);
this.preload.addEventListener("error", this.fileError);
this.preload.setMaxConnections(5);
this.loadAnother();
},
loadAnother: function () {
var myItem = this.fileList.shift();
if(this.fileList.length != 0) {
this.preload.loadFile(myItem);
}
},
fileLoaded: function (e) {
debug('Loaded ' + e.item.src);
debug(this.fileList);
},
fileError: function (e) {
debug('Error ' + e.item.src);
}
}