We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I understand, that the title of the post is not too informative, unfortunately I don't know where the problem lies.
Some background, a student of mine was playing with Processing and wanted to post his results. However, even though his program runs nicely in Java mode, it stops working properly in JavaScript.
Here is the link to her project: http://www.openprocessing.org/sketch/200423
I guess the problem has something to do with syntax or functions that work differently in JS as opposed to J.
Any help would be most welcome, Alex
Answers
"Uncaught TypeError: number is not a function".
function
, even though that variable doesn't hold a reference for such anymore.number
, therefore losing thefunction
's reference it once had.()
.()
is an operator which tries to use the reference stored in a variable as afunction
call.function
, an Error is thrown, the "Uncaught TypeError: xxx is not a function". >-)number
.function
. Even though it's anumber
now! ;;)Thanks a lot - I will show the post, and we will try to figure it out)
The variables (fields) named
size
are first suspect. Try to rename them and see if there is an improvement. Hint: the syntax coloring can help in finding the culprits.Hi, thank you for help, after 10+ times rerunning the code we have found the problem. And it was, indeed, related to a number variable being used as a function.
However, we are stuck with yet another glitch. For some strange reason the code restarts itself after a period of time.
The first thing the program does - it sets the coordinates for the asteroids in the "setup" part. This means that if the asteroids change their place over time, and they do, the program somehow runs the "setup" part again, which is something I can't understand.
This is the link: http://www.openprocessing.org/sketch/201071