누군가 내게 왜 내을 얻고 있는지 말해 줄 수 있습니까?successCallback이 함수가 아닙니다.
function fillData(data){
this.raw = data;
}
function AnimatedModel(posx, posy, posz,sx,sy,sz,r,g,b,a, name, yd){
this.x = posx;
this.y = posy;
this.z = posz;
this.scale = new Array(sx,sy,sz);
parseBinFile(this, name)
this.r = r;
this.g = g;
this.b = b;
this.a = a;
this.yawDeg = yd;
this.fillData = fillData;
}
var zombie = new AnimatedModel(0,0, 0, 0.2,0.2,0.2, 0.0,1.0,0.6,0.2, "zom3.ms3d", 0);
function parseBinFile(model, name){
getServerFileToArrayBufffer(name, model.fillData)
console.log(model.raw);
}
function getServerFileToArrayBufffer(url, successCallback){
// Create an XHR object
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == xhr.DONE) {
if (xhr.status == 200 && xhr.response) {
// The 'response' property returns an ArrayBuffer
successCallback(xhr.response);
} else {
alert("Failed to download:" + xhr.status + " " + xhr.statusText);
}
}
}
// Open the request for the provided url
xhr.open("GET", url, true);
// Set the responseType to 'arraybuffer' for ArrayBuffer response
xhr.responseType = "arraybuffer";
xhr.send();
}
편집 :
이
그것을 호출하는 코드 인 fillData 기능을 잊어 버렸습니다. 당신이 당신에게 문제의 원인이되는 전화입니다 그렇다면AnimatedModel
에
fillData
속성을 설정하기 전에 당신은
AnimatedModel
생성자
parseBinFile()
를 호출
음 "fillData"값의 출처는 어디입니까? 그것이 "successCallback"으로 전달하는 것입니다. 그것은 기능이 아닌 것으로 보이는 것입니다. – Pointy
나는 그것을 단지 잊었다. 이전과 같은 오류. – CyanPrime
'successCallback'은 함수가 아닙니다. ('getSever..'는'model.fillData'라고 불리우며, * parseBinFile이 호출 될 때까지 * 속성이 설정되지 않기 때문에 * undefined *로 평가됩니다. 따라서 successCallback은 * 정의되지 않았습니다 * : JavaScript는 * strictly입니다. 평가 *.) –