driz Posted November 29, 2010 Share Posted November 29, 2010 Hi I have the following Canvas application: http://dev.driz.co.uk/canvas/But it's not rendering anything out. It should be showing a bunch of balls that move around the screen when the user moves the cursor.I think it's just a small bug somewhere because it was working fine in an older version here: http://dev.driz.co.uk/app/It's taking a while to load as if it's doing something but just snagging somewhere, but the code looks fine to me. After testing in Firebug the following error comes up: 'Cannot read property x of undefined on several lines mainly around the gradient creation. I have no idea what the problem is :/If anyone can help it'd be much appreciated. Thank you Link to comment Share on other sites More sharing options...
driz Posted November 29, 2010 Author Share Posted November 29, 2010 Anyone had chance to look at this yet? Thanks. Link to comment Share on other sites More sharing options...
Ingolme Posted November 29, 2010 Share Posted November 29, 2010 The page is acting like if there was an infinite loop or something else that takes a whole long time to process. You might be doing something that's too heavy on the processor. I'm not getting error messages because the script couldn't finish executing. Link to comment Share on other sites More sharing options...
driz Posted November 29, 2010 Author Share Posted November 29, 2010 The page is acting like if there was an infinite loop or something else that takes a whole long time to process. You might be doing something that's too heavy on the processor. I'm not getting error messages because the script couldn't finish executing.When I run it in Firebug it throws an error about "Cannot read property x of undefined" and then also "Cannot read property color of undefined" I think their is definitely a bug in the code but I'm not sure what the problem is.I wouldn't think it would be too hard on the processor as I had a previous version working fine before and all I have added is the gradient and also reduced the number of balls down to two so therefore it should run fine. Seems like their is a bug in the code rather than performance problem. I think the bug is also causing the app to run infinite, perhaps I don't need the setInterval but that's required for the update of the canvas when the mouse moves the balls.If you or anyone can take a look at the code and see what the problem is that'd be really awesome. Thanks. Link to comment Share on other sites More sharing options...
Ingolme Posted November 29, 2010 Share Posted November 29, 2010 I have a feeling that it's trying to find more balls than there are. It looks for ball, but if is greater than the amound of balls there are it will be undefined.Rather than checking for i < numBalls try using i < balls.length in all the loops (except the one that creates the balls)Also, test it with only a few balls first, like 10 or so. Link to comment Share on other sites More sharing options...
driz Posted November 29, 2010 Author Share Posted November 29, 2010 Hi I have tried that but it doesn't seem to have fixed anything. Have I changed the correct loops? (I've updated the code at http://dev.driz.co.uk/canvas/) Link to comment Share on other sites More sharing options...
driz Posted November 30, 2010 Author Share Posted November 30, 2010 It also just crashed Chrome, which displayed a message about the script using too much memory, I think it's just looping over and never actually rendering anything. I've changed those two loops but still not working... any ideas? Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.