2014-05-14 6 views
0

다음 범위에 대해 올바른 눈금 표시가 표시되지 않습니다. tick.scope의 외침에는 top-declared vars가 있습니다. 여기에 더 나은 이해를 위해 는 바이올린입니다 : 당신은 변경해야 myFiddle올바른 바인딩을 얻는 방법?

ole.prototype = { 
    TILE_SIZE: 480, 
    DEST_WIDTH: 1920, 
    init: function() { 
     console.log("test1: ", this.TILE_SIZE); 
     //document.body.addEventListener('mousemove', ??????.bind(this.onMouseMove, this)), 
     this.tick(); 
     $(window).on('anim_frame', ?????.bind(this.tick, this)) 
    }, 
    tick: function() { 
     console.log("test2: ", this.TILE_SIZE); 
     console.log("tick done once: DEST_WIDTH: ",this.DEST_WIDTH);   
     zaehler++; 
     console.log("ticker tick: ",zaehler);    

    }, 
+1

당신이 확실하지 않은 경우 how .bind' (또는 모든 기능)이 작동하면 MDN 설명서를 읽는 것이 좋습니다. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind –

답변

관련 문제