I want to call my methid animate indefinetely using requestAnimationFrame. However , the approach I am using does not seem to work.. Here are my codes ..
<html>
<head>
<meta charset="utf-8">
<script>
function object(){
this.index = 0;
}
object.prototype.animate = function(){
alert("vimak");
window.webkitRequestAnimationFrame( self.animate);
}
me = new object();
me.animate();
</script>
</head>
<body>
</body>
</html>
it gives me the folowing error..
Uncaught Error: TYPE_MISMATCH_ERR: DOM Exception 17
How do I fix this ?
Edited version
<html>
<head>
<meta charset="utf-8">
<script>
function object(){
this.index = 0;
}
object.prototype.animate = function(){
var that = this;console.log(that);
window.webkitRequestAnimationFrame( that.animate);
}
me = new object();
me.animate();
</script>
</head>
<body>
</body>
</html>
The output is
object
requestAnimationFrame.html:12
Window
requestAnimationFrame.html:12
Uncaught Error: TYPE_MISMATCH_ERR: DOM Exception 17
How do I make this work ?
You must think (debug) about what mean
selfon that context.Use a local variable to bind original context:
Or use the
bindfunction: