javascript - this inside callback function -
this question has answer here:
here situation.
function bird() { this._canfly = true; this._legs = 2; this._flying = false; } bird.prototype = { fly: function() { if ( this.canfly ) { layer.on('fly', function() { this.setstrokewidth(4); //this refers layer(kinetic.js) object this._flying = true; //this refers bird object }); }//end if } //end function ); here need access both layer object , bird object inside callback function. can tell me how handle above situation ?
var self = cache reference this refer when changes context.
Comments
Post a Comment