Saturday 15 February 2014

Javascript loop only works if I do an alert() -


I am working on a JavaScript spinning wheel, but I can just run it by inserting an alert (method), below (And then click on Chrome to constantly ignore messages)

  $ (document) .ready (function () {var color = ["# 000000", "#FFFFFF", " #FFFFFF "," #FFFFFF "]; arc = Math.PI / 2; var ctx; on startAngle = 0; function drawWheel (startAngle) {var canvas = document.getElementById (" wheel "); if (canvas. GetContext) {// Checks for external radius = 200 on browser support, innerRadius = 1 ; Ctx = canvas.getContext ("2D"); ctx.strokeStyle = "black"; ctx.lineWidth = 2; (for I = 0; I & lt; 4; i ++) {// To support the shape of the angle of change wheel on the start = startAngle + i * arc; ctx.fillStyle = color [i]; ctx.beginPath (); ctx.arc (250, 250, outerRadius, angle, angle + arc, false) ); Ctx.arc (250, 250, innerRadius, angle + arc, angle, true); ctx.stroke (); ctx.fill ();}}} function clearWheel () {var canvas = document .getElementById ("wheel "); Ctx = canvas.getContext ("2D"); Ctx.clearRect (0,0,500,500);} I = 0; While (i & lt; = 500) {// Warning (i); DrawWheel (I); I ++;}});  

I will put a breakpoint in the loop to ensure that the code is running. The warning code should not have any effect on the code.

Attaching a debugger can also expose a pressed error message that you are not seeing while running in normal mode.

No comments:

Post a Comment