jjwallace Posted March 25, 2016 Share Posted March 25, 2016 Uncaught ReferenceError: tempScope is not defined creature[e].anim.onLoop.add(function(tempScope){ console.log("Loops"); console.log('animation complete'); //creature[e].anim.remove(); tempScope.loadTexture('organism'+tempScope.varType); //temp scope = this = creature[e] ?? tempScope.angle *= -1; tempScope.x = -1000; tempScope.y = tempScope.world.randomY; tempScope.varSpeed = Math.floor((Math.random() * 4) + 1); }, this); Link to comment Share on other sites More sharing options...
mattstyles Posted March 26, 2016 Share Posted March 26, 2016 `tempScope` is a parameter of the function, if this parameter is not passed to the function then its reference becomes undefined, if you try and operate on it then the runtime will throw an error. Whatever `creature[e].anim.onLoop.add` is doing with the callback you supplied, it isnt passing anything to the function. Link to comment Share on other sites More sharing options...
drhayes Posted March 26, 2016 Share Posted March 26, 2016 Where does tempScope come from? Is it just outside that code you pasted? If it is, you can just use the value inside the closure. Link to comment Share on other sites More sharing options...
Recommended Posts