javascript - Reference error while trying to encapsulate an animation function -
i'm trying put function own class object. here below.
the canvas property holds dom functions, , getting error next property, ctx, should refer method defined in canvas.
so property ctx should refer ctx method defined in canvas property. bt when page loads, dev tools telling me there reference error @ point - canvas not defined.
i encounter problem when canvas defined in external global variable.
var drawcrash = { canvas : function () { dom methods here }, ctx : canvas.ctx, pointer : canvas.pointer, particles : "", nbrparticles : 160, speed : 6, strength : .4, radius : 4, perspective : 0.5, ang : null, cosorsin1 : null, cosorsin2 : null, //functions setspeed : function (_inputspeed) { this.speed = _inputspeed; }, startdrawing : function () { pointer.down = function() { } } run(); } }
i believe canvas not available. don't put line ctx: canvas.ctx
. instead define in separate statement after this.
drawcrash.ctx = drawcrash.canvas.ctx
you trying reference before created
Comments
Post a Comment