I am currently attempting to extract and update global variables from inside of an requestAnimationFrame()
loop. The global variables inside of this scope does not update and am searching for a way to update the variables.
Here is a sample of my code (full source can be found at clmtrackr-clm_Video):
Var _myGlobal = "one";
function drawLoop() {
requestAnimFrame(drawLoop);
overlayCC.clearRect(0, 0, 400, 300);
//psrElement.innerHTML = "score :" + ctrack.getScore().toFixed(4);
if (ctrack.getCurrentPosition()) {
ctrack.draw(overlay);
_myGlobal = "two";
document.getElementById('tester').innerHTML = _myGlobal; //prints "two"
}
}
document.getElementById('tester').innerHTML = _myGlobal; //prints "one"
Note: I am trying to pass out the values while the video is still running (animationframe
).
Any help would be much appreciated.
Thanks.